Skip to content

Commit 89169d8

Browse files
author
Mike Fairhurst
committed
Exists statement on a property is no more :(
1 parent abf6ac0 commit 89169d8

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

src/cpp/TypeChecker.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,7 @@ Type* TypeChecker::typeCheck(Node* tree) {
674674
real->optional = 0;
675675

676676
if(tree->node_data.nodes[0]->node_type == NT_MEMBER_ACCESS) {
677-
scopesymtable->pushScope();
678-
scopesymtable->add(real);
677+
errors->addError(new SemanticError(TYPE_ERROR, "Calling exists { } on a property is illegal as it is a shared reference and therefore might be unset amid the scope"));
679678
} else {
680679
scopesymtable->addOverwriting(real);
681680
}

src/cpp/test/ParseTreeTraverserTest.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,4 +2348,14 @@ PTT_TEST_CASE(
23482348
PTT_EXPECT(SYMBOL_ALREADY_DEFINED)
23492349
);
23502350

2351+
PTT_TEST_CASE(
2352+
TestExistsOnAPropertyIsDisallowed,
2353+
"every MyClass is: \n\
2354+
with Num? = nothing; \n\
2355+
callExistsOnProperty() { \n\
2356+
if Num exists {} \n\
2357+
}",
2358+
PTT_EXPECT(TYPE_ERROR)
2359+
);
2360+
23512361
BOOST_AUTO_TEST_SUITE_END()

src/wake/test/SimpleGeneric.wk

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ every SimpleGeneric{T1, T2} is:
2424
}
2525

2626
T1 -- getT1Otherwise($T1) {
27-
if T1 exists {
28-
return T1;
27+
var $$T1? = T1;
28+
if $$T1 exists {
29+
return $$T1;
2930
}
3031
return $T1;
3132
}
@@ -35,8 +36,9 @@ every SimpleGeneric{T1, T2} is:
3536
}
3637

3738
T2 -- getT2Otherwise($T2) {
38-
if T2 exists {
39-
return T2;
39+
var $$T2? = T2;
40+
if $$T2 exists {
41+
return $$T2;
4042
}
4143
return $T2;
4244
}

0 commit comments

Comments
 (0)