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

wat2wasm gives error: unexpected token get_local #1802

Closed
SathoriStudio opened this issue Jan 11, 2022 · 6 comments
Closed

wat2wasm gives error: unexpected token get_local #1802

SathoriStudio opened this issue Jan 11, 2022 · 6 comments

Comments

@SathoriStudio
Copy link

I have downloaded wabt in my Linux Mint machine, but when I try to use the wat2wasm file.wat command into a simple example like this, it gives me error.

(module
(func $add (param $lhs i32) (param $rhs i32) (result i32)
get_local $lhs
get_local $rhs
i32.add)
(export "add" (func $add))
)

This is the error:

add1.wat:3:5: error: unexpected token get_local, expected ).
    get_local $lhs
    ^^^^^^^^^
add1.wat:4:5: error: unexpected token get_local.
    get_local $rhs

The same code in the wat2wasm online demo works fine. When I use wat2wasm --version it says my version is 1.0.25.

Any ideas of why the unexpected token get_local error appears? Thanks in advance.

@graial
Copy link

graial commented Jan 12, 2022

I had the same experience on arch linux when I cloned the repo
However, the error was gone when I downloaded the latest release instead

@SathoriStudio
Copy link
Author

Thanks for the advice, @graial !

I have downloaded the wabt-1.0.24-ubuntu.tar.gz release and now it seems that wat2wasm is working fine. I also didn't need to "build" using CMake or anything similar, so I suppose that I should have started with the release. Thanks!

@dgruntz
Copy link

dgruntz commented Apr 17, 2022

I had the same problem, but I could fix it by replacing get_local by local.get.

@sbyun
Copy link

sbyun commented Apr 17, 2022

Thanks dgruntz. It worked for me.

@xgqfrms
Copy link

xgqfrms commented Sep 5, 2022

I had the same problem, but I could fix it by replacing get_local by local.get.

So, what's wrong with that?

Are compiler versions different?

The old version uses get_local , but the new version use local.get.

same question

https://www.cnblogs.com/xgqfrms/p/16658111.html

@keithw
Copy link
Member

keithw commented Sep 5, 2022

Please see #1883 -- get_local isn't a valid instruction in WebAssembly. (It used to be called that when WebAssembly was in draft form, but the names were changed in 2018 before the WebAssembly 1.0 spec was published, and wabt dropped support for the draft names in 2021 (#1792).)

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

6 participants