-
Notifications
You must be signed in to change notification settings - Fork 1
Description
What is the problem?
Currently the code accepted (and then, further parsed) by the compiler in %wasm
blocks is not regular WAT syntax, but effectively a dialect.
As a simple example, the following WAT:
(loop $loop (block $a_block
(i32.sub (local.get $i) (i32.const 1))
(local.get $i)
i32.eqz
(br_if $a_block)
br $loop))
semantics aside — syntactically it is correct. I've verified this by including the above snippet as part of a WASM (func)
and passing it to wasmtime
.
Unfortunately under the current grammar rules it'll be regarded as invalid syntax and rejected by the compiler.
Expected behaviour
Both the syntax (%wasm
token) and all the current usage implies that any valid WAT should be accepted.
Proposed Solution
It's not as cut-and-dry as correcting the grammar alone, because - as mentioned above - the compiler must itself parse the code inside those blocks. Such a solution would create even bigger problems down the pipe.
So to really solve this we have, as I see it, two options:
- Live with it for the time being (until version 1..?). Making some kind of small change hinting at the fact that what you put inside those blocks is not straight-up WAT but a limited subset instead.
- Make all the sweeping changes that accepting all forms of WAT would entail right now, although this would be a very big undertaking without any "immediate" gain.