WebAssembly / WebAssembly/binaryen
wasm-opt: tables cannot be declared after functions
Nobody has claimed this yet.
- Dominant language
- WebAssembly
- Stars
- 8.6k
- Forks
- 885
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 69
Description
wasm-opt appears to expect tables in textual wast to be declared before any function bodies, but some utilities such as wabt's wasm2wast always places it after, near the bottom of the file.
[parse exception: no table]Fatal: error in parsing input
If I move the table text above the functions, the issue resolves.
(module
(type $t0 (func))
+ (table 1 anyfunc)
(func $f0 (type $t0))
(func $f1 (type $t0)
(call_indirect $t0
(i32.const 0)
)
)
- (table 1 anyfunc)
(elem (i32.const 0) $f0)
)
I recall seeing a rough spec for the textual format but can't seem to find it right now to see whether binaryen or wabt is at fault or if this is just undefined behavior. I only see the super high level Text Format page.
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
Start with src/wasm/wasm-s-parser.cpp around line 1356 and reproduce the failure using wasm-opt with the textual module shown in the issue. Compare parsing when the table follows the function bodies versus when it precedes them, and check the WebAssembly text-format expectations. Done means valid input from wabt's wasm2wast is accepted without requiring the table to be moved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, wasm
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100