Debian Codegraph @

src/test/01-Basic/195-value-lookup-order.ck

raw
1 // github era issue #6 (2014)
2 // https://github.com/ccrma/chuck/issues/16
3 // finally resolved (2023)
4
5 // should print three 3000s in B.bar(),
6 // value lookup should prioritize local variable foo over
7 // A.foo (1000) and the global-scope foo (2000)
8
9 // class A
10 class A
11 {
12 // member var
13 1000 => int foo;
14 }
15
16 // global scope var of same name
17 2000 => int foo;
18
19 // class B subclass of A
20 class B extends A
21 {
22 // function
23 fun void bar()
24 {
25 // local var
26 3000 => int foo;
27
28 // 1000
29 <<< "a", foo >>>;
30 {
31 // 1000
32 <<< "b", foo >>>;
33 }
34 // 1000
35 <<< "c", foo >>>;
36 }
37 }
38
39 B b;
40 b.bar();