WebAssembly / WebAssembly/wabt
`wast2json` miscompiles "if.wast" from the specification tests
Open
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 8.1k
- Forks
- 827
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 18
Description
The following WAST test expression from if.wast miscompiles, omitting the empty else block:
(assert_invalid
(module (func $type-else-value-empty-vs-num (result i32)
(if (result i32) (i32.const 1) (then (i32.const 0)) (else))
))
"type mismatch"
)
$ wast2json if.wast
$ wasm-objdump -x -d if.0.wasm
if.0.wasm: file format wasm 0x1
Section Details:
Type[1]:
- type[0] () -> i32
Function[1]:
- func[0] sig=0
Code[1]:
- func[0] size=9
Code Disassembly:
000017 func[0]:
000018: 41 01 | i32.const 1
00001a: 04 7f | if i32
00001c: 41 00 | i32.const 0
00001e: 0b | end
00001f: 0b | end
WABT version: 0df6c26d2a6122afcc2c32ff6b608326258d40d9
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with wast2json if.wast, then inspect the wast2json entry point and the handling of the WAST if expression containing an empty else block. Compare the generated if.0.wasm with the source expression and wasm-objdump output; done means the empty else block is preserved and the invalid type mismatch remains represented correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100