Debian Codegraph @

src/test/06-Errors/error-public-class-ext-var1.ck

raw
1 // error verification
2 // external var access from public class function
3 //
4 // NOTE this should not work (unless explicitly declared as
5 // 'global') and should result in an error, as public class X
6 // uses 'foo', but 'foo' only exists per-file is only valid
7 // if X is instantiated from the same file its declared in;
8 // however, a public class can be instantiated from any file,
9 // and the access of 'foo' would not make sense
10
11 // file-level variable
12 7 => int foo;
13
14 // public classes can be instantiated from any file
15 public class X
16 {
17 fun void go()
18 {
19 // using an external variable from within a public class
20 // things gets weird if X is instantiated from another file
21 <<< foo + 5 >>>;
22 }
23 }