Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local.get or get_local #1105

Open
coderaiser opened this issue Jun 6, 2022 · 2 comments
Open

local.get or get_local #1105

coderaiser opened this issue Jun 6, 2022 · 2 comments

Comments

@coderaiser
Copy link

MDN says and wabt thinks that local.get:

inline:4:7: error: unexpected token get_local, expected ).
      get_local $n1
      ^^^^^^^^^

With such code:

import { traverse } from "@webassemblyjs/ast";
import { parse } from "@webassemblyjs/wast-parser";

const code = `
  (module
    (func (export "add") (param $n1 i32) (param $n2 i32) (result i32)
      local.get $n1
      local.get $n2
      i32.add)
  )
`;

const ast = parse(code);

I see crash:

/Users/coderaiser/webasm/node_modules/@webassemblyjs/wast-parser/lib/grammar.js:946
            return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "Unexpected token in instruction argument" + ", given " + tokenToString(token));
                   ^

Error:
  (module
    (func (export "add") (param $n1 i32) (param $n2 i32) (result i32)
      local.get $n1
      local.get $n2
     ^^^^^
      i32.add)
  )


Unexpected token in instruction argument, given name
    at /Users/coderaiser/webasm/node_modules/@webassemblyjs/wast-parser/lib/grammar.js:946:20
    at parseFuncInstrArguments (/Users/coderaiser/webasm/node_modules/@webassemblyjs/wast-parser/lib/grammar.js:947:12)
    at parseFuncInstr (/Users/coderaiser/webasm/node_modules/@webassemblyjs/wast-parser/lib/grammar.js:1068:37)
    at parseFunc (/Users/coderaiser/webasm/node_modules/@webassemblyjs/wast-parser/lib/grammar.js:1182:23)
    at walk (/Users/coderaiser/webasm/node_modules/@webassemblyjs/wast-parser/lib/grammar.js:1623:22)
    at parseModule (/Users/coderaiser/webasm/node_modules/@webassemblyjs/wast-parser/lib/grammar.js:858:27)
    at walk (/Users/coderaiser/webasm/node_modules/@webassemblyjs/wast-parser/lib/grammar.js:1635:22)
    at Object.parse (/Users/coderaiser/webasm/node_modules/@webassemblyjs/wast-parser/lib/grammar.js:1776:15)
    at parse (/Users/coderaiser/webasm/node_modules/@webassemblyjs/wast-parser/lib/index.js:33:20)
    at file:///Users/coderaiser/webasm/index.mjs:14:13
@d3lm
Copy link

d3lm commented Jun 14, 2022

get_local is the old WAST syntax. I think the AST validator needs to be updated because right now it only accepts get_local for local.get.

@xtuc
Copy link
Owner

xtuc commented Jul 2, 2022

Make sense. Please feel free to submit a change

Repository owner deleted a comment from Fixw31 Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants