You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that there's no space between the i32.const and the 0. This doesn't create any actual ambiguity, but it doesn't seem to add meaningful flexibility either, and it's surprising.
For reference, wabt and binaryen both issue errors on this code.
Hm, interesting. That is a normal result of the usual longest match rule for lexing. But it seems that for an S-expression format that is not actually a desirable logic to use.
@binji, yes, I just implemented the same rule. It's a bit more interesting how to specify it, though. Probably gonna do a similar trick in the spec itself, defining a general syntax for atoms, wth all other ones being "reserved".
I'm thinking about fixing this in WAVM by only matching a keyword or number if it's followed by a token separating character (without consuming that character).
Actually, it seems easy to fix by just removing the bit that a bogus "keyword" starts with a letter. See latest patch, which also adjusts the spec text.
changed the title [-][spec/interpreter] Accepts "i32.const0" (missing space)[/-][+][spec+interpreter] Accepts "i32.const0" (missing space)[/+]on May 18, 2017
Activity
rossberg commentedon May 16, 2017
Hm, interesting. That is a normal result of the usual longest match rule for lexing. But it seems that for an S-expression format that is not actually a desirable logic to use.
binji commentedon May 16, 2017
I don't remember doing it, but it looks like I added a rule a while back that prevented this in the wabt lexer: https://github.com/WebAssembly/wabt/blob/master/src/wast-lexer.cc#L464
Removing that rule makes wabt work the same, allowing you to parse modules like:
(module(func(resulti32)i32.const0)):-)rossberg commentedon May 16, 2017
@binji, yes, I just implemented the same rule. It's a bit more interesting how to specify it, though. Probably gonna do a similar trick in the spec itself, defining a general syntax for atoms, wth all other ones being "reserved".
rossberg commentedon May 16, 2017
Okay, I refined PR #471 to rule out such cases and adjust the interpreter accordingly.
AndrewScheidecker commentedon May 17, 2017
@rossberg-chromium I don't think your change rejects a keyword following a number:
offset=1align=1rossberg commentedon May 17, 2017
@AndrewScheidecker, works for me. Note that the sequence
offset=1align=1forms a single "keyword" under the given grammar. There is no number.rossberg commentedon May 17, 2017
Ah, but you are right nevertheless!
(module (func br 0nop))is still accepted. Hm, darn, not sure how to solve this.AndrewScheidecker commentedon May 17, 2017
I'm thinking about fixing this in WAVM by only matching a keyword or number if it's followed by a token separating character (without consuming that character).
rossberg commentedon May 17, 2017
Actually, it seems easy to fix by just removing the bit that a bogus "keyword" starts with a letter. See latest patch, which also adjusts the spec text.
[-]interpreter accepts "i32.const0" (missing space)[/-][+][spec/interpreter] Accepts "i32.const0" (missing space)[/+][-][spec/interpreter] Accepts "i32.const0" (missing space)[/-][+][spec+interpreter] Accepts "i32.const0" (missing space)[/+]rossberg commentedon Jun 29, 2017
This has been resolved as part of PR #471.
Merge pull request WebAssembly#478 from ShinWonho/ref.null