Debian Codegraph @

src/test/06-Errors/error-depend-nest1.ck

raw
1 // error case: test for dependency through transitive function calls
2 // i.e., in this case, nest() essentially inherits the dependencies
3 // of printArray() which includes 'array'
4
5 // nest function definition
6 fun void nest()
7 {
8 // causes nest to inherit printArray()'s dependencies
9 printArray();
10 }
11
12 // should not work here, since nest() needs printArray()
13 // which needs 'array', but nest() is called before 'array'
14 // initializes
15 nest();
16
17 // 'array' initializes here
18 [1, 2, 3] @=> int array[];
19
20 // function definition
21 fun void printArray()
22 {
23 // access 'array'
24 <<< array[0], array[1], array[2] >>>;
25 }