Debian Codegraph @

src/test/01-Basic/270-var-func-order.ck

raw
1 // test using a local variable declared after a function that uses that variable
2 //
3 // added 1.5.4.4; previously this would cause a crash because the emitter
4 // emitted foo() first, at which point the variable `osc` has not yet received
5 // it's stack offset, since `SinOsc osc(440);` appears later in the file
6 // fix: now code emisison is sorted for file-level code, function defs, class
7 // defs.
8
9 // function def
10 fun void foo()
11 {
12 // uses `osc`
13 if( Math.equal(osc.freq(),440) ) <<< "success" >>>;
14 }
15
16 // osc is declared
17 SinOsc osc(440);
18
19 // call foo
20 foo();