-
-
Notifications
You must be signed in to change notification settings - Fork 667
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
Emit warning on generic function/class export #981
Conversation
4064d87
to
af4d261
Compare
af4d261
to
76b7f99
Compare
The way this currently works is that if one does export class Foo<T> {
bar(a: T): T {
return a;
}
} while it cannot be automatically compiled due to missing context, if there is var foo = new Foo<i32>();
foo.bar(1); somewhere in the code one will still get a |
@9oelM Yes, I guess warning will be more prefer |
@dcodeIO |
What I'm trying to get at is that exporting a generic function or class does actually work iff there is a concrete usage of the function or class within the module. Only if there is no concrete usage, there won't be a respective export. Still uncertain how to handle this properly, but perhaps we should attempt to detect generic exports that don't have any concrete usage and only then emit a warning? For an example of what I mean, compile export class Foo<T> {
bar(a: T): T {
return a;
}
}
var foo = new Foo<i32>();
foo.bar(1); with
and you'll notice that there is an export named (export "Foo<i32>#bar" (func $index/Foo<i32>#bar))
(func $index/Foo<i32>#bar (param $0 i32) (param $1 i32) (result i32)
local.get $1
) |
@dcodeIO I get what you mean now. For now, I think it would be a good idea to just emit a warning if there is no concrete usage inside the module itself. |
One strategy to implement this could be to compile the module normally, inspecting module-level exports right before finishing compilation, emitting the warning if the respective |
@dcodeIO Will try that. |
Without knowledge that exporting a generic function/class is not possible (yes.. I was dumb..), I wasted my time figuring things out on my own.
When I googled and finally found #570, I wanted to improve this.
runTest
function to consumestdout
Would resolve #570