Closed ion1 closed 2 months ago
This compiles. My editor says the return type of call(print, ...) is [StackVar<"i32">].
call(print, ...)
[StackVar<"i32">]
const print = importFunc( { in: [i32, i32, i32, i32, i32, i32, i32], out: [i32] }, () => {} ); const printCentered = func( { in: [i32, i32, i32, i32, i32, i32, i32], out: [i32], locals: [] }, ([text, x, y, color, fixed, scale, small]) => { const [width] = call(print, [text, 0, -6, color, fixed, scale, small]); const newX = i32.sub(x, i32.div_s(width, 2)); return call(print, [text, newX, y, color, fixed, scale, small]); } );
However, it fails at runtime with TypeError: call is not a function or its return value is not iterable.
TypeError: call is not a function or its return value is not iterable
Changing
- const [width] = call(print, [text, 0, -6, color, fixed, scale, small]); + const width: any = call(print, [text, 0, -6, color, fixed, scale, small]); + console.info(width);
makes it work and prints { kind: 'stack-var', id: 16, type: 'i32' } which is indeed not an array.
{ kind: 'stack-var', id: 16, type: 'i32' }
Thanks for finding that, a type bug I will fix
Fixed and released as 0.2.3
This compiles. My editor says the return type of
call(print, ...)
is[StackVar<"i32">]
.However, it fails at runtime with
TypeError: call is not a function or its return value is not iterable
.Changing
makes it work and prints
{ kind: 'stack-var', id: 16, type: 'i32' }
which is indeed not an array.