| 1 |
// test for dependency through transitive function calls |
| 2 |
// i.e., in this case, nest() essentially inherits the dependencies |
| 3 |
// of printArray() which include 'array'. Since nest() is called |
| 4 |
// after 'array' initializes, we are good |
| 5 |
|
| 6 |
// nest function definition, which can be anywhere in the code |
| 7 |
// as long as calling this function doesn't precede any needed |
| 8 |
// variable initialization |
| 9 |
fun void nest() |
| 10 |
{ |
| 11 |
// causes nest to inherit printArray()'s dependencies |
| 12 |
printArray(); |
| 13 |
} |
| 14 |
|
| 15 |
// 'array' initializes here |
| 16 |
[1, 2, 3] @=> int array[]; |
| 17 |
|
| 18 |
// should work here, since we calling nest() after 'array' init |
| 19 |
nest(); |
| 20 |
|
| 21 |
// function definition |
| 22 |
fun void printArray() |
| 23 |
{ |
| 24 |
// access 'array' |
| 25 |
<<< array[0], array[1], array[2] >>>; |
| 26 |
} |