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

wasm-merge: check that the types of imports and exports match. #6437

Merged
merged 2 commits into from
Mar 27, 2024

Conversation

vouillon
Copy link
Contributor

No description provided.

@vouillon vouillon force-pushed the merge-typing branch 4 times, most recently from 60a2fc4 to 65b6a70 Compare March 25, 2024 23:02
@vouillon vouillon marked this pull request as ready for review March 25, 2024 23:03
Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good aside from 2 things.

src/wasm/wasm-s-parser.cpp Outdated Show resolved Hide resolved
void reportTypeMismatch(bool& valid, const char* kind, Importable* import) {
valid = false;
std::cerr << "Type mismatch when importing " << kind << " " << import->base
<< " from module " << import->module << ": ";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can also print the import->name here. That would differentiate imports with the same module/base but different internal names, which happens in the test (which is good to test, that's an important corner case).

Suggested change
<< " from module " << import->module << ": ";
<< " from module " << import->module << "(" << import->name << "): ";

Please add internal names to the test, so that this information becomes more useful (rather than the parser autogenerating internal names).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The internal name is usually not very informative. One often reuses the same name as the base:

(import "env" "foo" (func $foo ...)

So, I'm concerned that the import could get quite often renamed, and thus that printing this new name might actually be confusing. The best thing to do would be to print the initial name as well as the name of the file containing this import, but we no longer have this information.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree the original file would be useful, yeah. Too bad we don't have it.

I still think the internal name can help. How informative it is depends on the toolchain, but regardless, when there are duplicate imports it is really the only way to differentiate anything. I do suggest (in the diff above) to put the internal name in parentheses because I agree it is less informative than the other information.

@kripken
Copy link
Member

kripken commented Mar 27, 2024

I fuzzed this for a while and saw no issues.

@kripken kripken merged commit eae2638 into WebAssembly:main Mar 27, 2024
14 checks passed
@vouillon vouillon deleted the merge-typing branch March 27, 2024 21:54
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

Successfully merging this pull request may close these issues.

None yet

2 participants