-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
The makepad-stitch interpreter evaluates the following .wast script incorrectly:
(module
(func (export "run") (param $cond i32) (param $x i32) (result i32)
(drop
(i32.add
(local.get $x)
(i32.const 10)
)
)
(local.get $x)
(block
(local.get $cond)
(br_if 0)
(local.set $x (i32.const 1))
)
)
)
(assert_return
(invoke "run" (i32.const 1) (i32.const 42))
(i32.const 42)
)What happens:
(local.get $x)puts$xon the stack.(br_if 0)breaks out ofblockbefore(local.set $x (i32.const 1))since$condis1- thus it is expected that
$xis still on the stack. however,makepad-stitchalways just returns0. - for
$cond = 0makepad-stitchactually returns$xback.
I have looked into makepad-stitch's code and think it might have to do with the fact that not all local variables on the stack are preserved (copied to temp stack slots) when entering a control frame such as block, if and loop.
I tested this manually with makepad-stitch's CLI tool installed via cargo install makepad-stitch.
cc @ejpbruel2
Metadata
Metadata
Assignees
Labels
No labels