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

Problem while parsing wat, if a map variable is defined #59

Open
hugo-dc opened this issue Dec 24, 2019 · 1 comment
Open

Problem while parsing wat, if a map variable is defined #59

hugo-dc opened this issue Dec 24, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@hugo-dc
Copy link
Member

hugo-dc commented Dec 24, 2019

If we define the following map:

let myMap = new Map<i32, i32>()

And try to build the WebAssembly module (for example `npm run evm:build) we get the following error:

[00:05:54] 'evm' errored after 5.36 s
[00:05:54] Error: parseWat failed:
evm_with_keccak.wat:379:25: error: unexpected char
 (func $~lib/map/Map<i32,i32>#clear (; 13 ;) (type $FUNCSIG$vi) (param $0 i32)
                        ^
evm_with_keccak.wat:379:26: error: unexpected token i32>#clear, expected ).
 (func $~lib/map/Map<i32,i32>#clear (; 13 ;) (type $FUNCSIG$vi) (param $0 i32)
                         ^^^^^^^^^^
evm_with_keccak.wat:379:63: error: unexpected token ), expected (.
 (func $~lib/map/Map<i32,i32>#clear (; 13 ;) (type $FUNCSIG$vi) (param $0 i32)
                                                              ^

    at Object.parseWat (/home/hugo/workspace/biturbo/node_modules/wabt/index.js:25:14653)
    at mergeWats (/home/hugo/workspace/biturbo/gulpfile.js:178:23)
    at buildEvm (/home/hugo/workspace/biturbo/gulpfile.js:49:3)
    at process._tickCallback (internal/process/next_tick.js:68:7)
@hugo-dc hugo-dc added the bug Something isn't working label Dec 24, 2019
@s1na
Copy link
Collaborator

s1na commented Jan 6, 2020

Sorry for the late response Hugo.

Casey had also faced this before and he added a workaround to the gulpfile which you can also use. Hopefully this issue should be fixed (maybe it already is) in wabt and we can avoid this hacky workaround.

biturbo/gulpfile.js

Lines 132 to 137 in 005b684

// remove commas from function names generated by binaryen to please wabt
let mainWatReplaced = mainWat.replace(/Uint\d+Array,/g, "Uint64Array");
//console.log('mainWatReplaced:', mainWatReplaced)
mainWatReplaced = mainWatReplaced.replace(/Map<usize,/g, "Map<usize");
//console.log('mainWatReplaced:', mainWatReplaced)
mainWatReplaced = mainWatReplaced.replace(/Uint\d+Array \| null/g, "UintArrayOrNull");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants