-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update var dependecy validation; fix overzealous validation
- Loading branch information
Showing
12 changed files
with
176 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// test declaring class members in a file below access | ||
|
||
class Foo | ||
{ | ||
// member variable, declare above access in ctors | ||
int m_a; | ||
|
||
// a constructor | ||
fun @construct( int n ) { n => m_a => m_b; } | ||
// another constructor | ||
fun @construct( int a, int b ) { a => m_a; b => m_b; } | ||
|
||
// member variable, declare below access in ctrs | ||
int m_b; | ||
} | ||
|
||
// instantiate with | ||
Foo foo( 1, 2 ); | ||
|
||
if( foo.m_a + foo.m_b == 3 ) <<< "success" >>>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// test declaring/instantation classes with inheritance, involving | ||
// a member variable, declared in the file below its access | ||
// was issue #376 | ||
|
||
public class Foo | ||
{ | ||
// this implicitly uses Bar.name, but okay since .name gets | ||
// initialized in pre-ctor before all this runs | ||
BarFactory.make() @=> Bar bar; | ||
// test new | ||
new BarChild @=> BarChild @ bc; | ||
// test decl | ||
BarChild bc2; | ||
} | ||
|
||
class Bar | ||
{ | ||
"i am bar" => string name; | ||
} | ||
|
||
class BarChild extends Bar | ||
{ | ||
"success" => name; | ||
} | ||
|
||
class BarFactory | ||
{ | ||
fun static BarChild make() | ||
{ | ||
return new BarChild; | ||
} | ||
} | ||
|
||
// make a Foo | ||
Foo foo; | ||
<<< foo.bar.name >>>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// test declaring/instantation classes with inheritance, involving | ||
// a member variable, declared in the file below its access | ||
|
||
class Bar | ||
{ | ||
// this implicitly uses Bar.name... | ||
// also would cause a infinite loop, but won't get that far | ||
BarFactory.make(); | ||
// the var | ||
"i am bar" => string name; | ||
} | ||
|
||
class BarChild extends Bar | ||
{ | ||
"success" => name; | ||
} | ||
|
||
class BarFactory | ||
{ | ||
fun static BarChild make() | ||
{ | ||
return new BarChild; | ||
} | ||
} | ||
|
||
// shouldn't quite get to here | ||
BarFactory.make(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
error-depend-class-extend.ck:8:16: error: calling 'make()' at this point skips initialization of a needed variable: | ||
[8] BarFactory.make(); | ||
^ | ||
error-depend-class-extend.ck:10:26: error: ...(note: this skipped variable initialization is needed by 'fun BarChild BarFactory.make()') | ||
[10] "i am bar" => string name; | ||
^ | ||
error-depend-class-extend.ck:15:18: error: ...(note: this is where the variable is used within 'fun BarChild BarFactory.make()' or its subsidiaries) | ||
[15] "success" => name; | ||
^ | ||
error-depend-class-extend.ck: ...(hint: try calling 'make()' after the variable initialization) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// within class definition of Foo, class member 'myVal' is used before declaration | ||
|
||
// class definition | ||
class Foo | ||
{ | ||
// no work -- depends on myVal being initialized | ||
<<< myVal >>>; | ||
|
||
// the dependency | ||
5 => int myVal; | ||
} | ||
|
||
// should have error'ed out by this point | ||
Foo foo; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
error-depend-class-var.ck:7:9: error: class member 'myVal' is used before declaration | ||
[7] <<< myVal >>>; | ||
^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
error-depend-var2.ck:4:5: error: variable/member 'a' is used before declaration | ||
error-depend-var2.ck:4:5: error: variable 'a' is used before declaration | ||
[4] <<< a >>>; | ||
^ |