Debian Codegraph @

src/test/01-Basic/190-class-auto.ck

raw
1 // auto can be used inside class defs EXCEPT
2 // top-level class members cannot be declared as auto
3 // introduced in 1.5.1.1 as class vars could be accessed
4 // from anywhere but currently there is no mechanism to
5 // resolve the 'auto' until type checking stage...
6
7 // class def
8 class Foo
9 {
10 // ok
11 for( auto x : [1,2,3] ) { <<< x >>>; }
12
13 // ok
14 fun void bar()
15 {
16 4 => auto y;
17 <<< y >>>;
18 }
19
20 // ok
21 if( true ) { 5 => auto x; }
22
23 // not ok
24 // 3 => auto m_var;
25 }
26
27 // instantiate foo
28 Foo foo;
29 // call bar()
30 foo.bar();