apoorvaanand1998 opened issue #10171:
(module (type $appNode (struct (field $left anyref) (field $right anyref))) (type $comb (struct (field $asciiTag i32))) (func $prob1 (export "prob1") (param $p (ref null $appNode)) (result i32) (local.get $p) (struct.get $appNode $left) (ref.cast (ref null $appNode)) (struct.get $appNode $right) (ref.test (ref null $comb)) ) (func $prob2 (export "prob2") (param $p (ref null $appNode)) (result i32) (local.get $p) (struct.get $appNode $left) (ref.cast (ref null $appNode)) (struct.get $appNode $left) (ref.test (ref null $comb)) ) (func $main (export "main") (result i32) (struct.new $appNode (struct.new $appNode (struct.new $comb (i32.const 67)) (struct.new $comb (i32.const 73))) (ref.i31 (i32.const 2))) (call $prob2) ) )Hey Wasmtime team!
calling$prob1returns 1 but$prob2returns 2. Why is that? Shouldn't it be reading thestruct.new $comb (i32.const 67)which indeed is acomb? I've tried reading the GC spec but haven't been able to figure out why the runtime behaves this way.
apoorvaanand1998 edited issue #10171:
(module (type $appNode (struct (field $left anyref) (field $right anyref))) (type $comb (struct (field $asciiTag i32))) (func $prob1 (export "prob1") (param $p (ref null $appNode)) (result i32) (local.get $p) (struct.get $appNode $left) (ref.cast (ref null $appNode)) (struct.get $appNode $right) (ref.test (ref null $comb)) ) (func $prob2 (export "prob2") (param $p (ref null $appNode)) (result i32) (local.get $p) (struct.get $appNode $left) (ref.cast (ref null $appNode)) (struct.get $appNode $left) (ref.test (ref null $comb)) ) (func $main (export "main") (result i32) (struct.new $appNode (struct.new $appNode (struct.new $comb (i32.const 67)) (struct.new $comb (i32.const 73))) (ref.i31 (i32.const 2))) (call $prob2) ) )Hey Wasmtime team!
calling$prob1returns 1 but$prob2returns 0. Why is that? Shouldn't it be reading the(struct.new $comb (i32.const 67))which indeed is acomb? I've tried reading the GC spec but haven't been able to figure out why the runtime behaves this way.
alexcrichton assigned fitzgen to issue #10171.
fitzgen commented on issue #10171:
This looks like a bug in Wasmtime, I think
prob2should indeed return1.FWIW, it also returns
1in Firefox.
fitzgen commented on issue #10171:
Interestingly enough, removing
$rightmakes the test pass.
fitzgen added the bug label to Issue #10171.
fitzgen added the wasm-proposal:gc label to Issue #10171.
Last updated: Dec 13 2025 at 19:03 UTC