-
Notifications
You must be signed in to change notification settings - Fork 91
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
fix: module imports should not use type index as their function identifier #411
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
(module | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this simple test, which adds a couple of type definitions, was enough to repro the issues from #406 |
||
(type (func (result i32))) | ||
(type (func (param i32) (result i32))) | ||
(import "a" "c" (func $fff (param i32) (result i32))) | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -405,8 +405,6 @@ export function parse(tokensList: Array<Object>, source: string): Program { | |
} | ||
|
||
const name = token.value; | ||
|
||
let fnName = t.identifier(`${moduleName}.${name}`); | ||
eatToken(); | ||
|
||
eatTokenOfType(tokens.openParen); | ||
|
@@ -419,6 +417,8 @@ export function parse(tokensList: Array<Object>, source: string): Program { | |
const fnParams = []; | ||
const fnResult = []; | ||
|
||
let fnName = t.identifier(getUniqueName("func")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this change was not necessarily needed to make tests pass, but this does mean we have the same generated names when parsing wat There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following https://github.com/xtuc/webassemblyjs/pull/411/files#r202406723 we could add our own func increment, or maybe we already have this information? |
||
|
||
if (token.type === tokens.identifier) { | ||
fnName = identifierFromToken(token); | ||
eatToken(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should try to eliminate the unique name generator (because statefull), and rather use the
typeindex
here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, that maybe the type name generator should be removed. I'm not sure what it's used for!
No ... that's the bug that this PR is fixing. Module imports are functions which are referenced by index, i.e. if you have the following:
The function
foo
has index0
, andbar
has index 1. The index does not relate to the type reference.