-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[WebIDL] Change generated statics to be accessed in the way the spec specifies #8706
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
Conversation
…ecifies According to the WebIDL spec static properties should be accessed like [class].[function], not [class]prototype.[function]. See: https://www.w3.org/TR/WebIDL/#idl-static-attributes-and-operations
|
I'm not familiar enough with WebIDL, but we have sort of assumed that "static" meant what it means in C/C++. It might be accurate either either way, though, assuming people don't manually change the prototype themselves. However, the test fails on CI here, so perhaps something is wrong? |
|
Yeah I just missed updating some tests. Hopefully that's all of them. Here's a cut down version of the example taken from the spec link posted above. IDL:
|
|
So I don't know why the filesize tests are now failing. The failing run printed: |
| console.log(succeeded); | ||
|
|
||
| TheModule.Child2.prototype.printStatic(); // static calls go through the prototype | ||
| TheModule.Child2.printStatic(); // static calls do not go through the prototype |
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.
would this still work with .prototype as well? if yes, then we should test both. if not, then it's a breaking change, and maybe not worth it.
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.
The old approach should work with or without .prototype, I think, so if we decide to not change this, maybe we can at least add testing and docs for not writing .prototype
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.
When I try and call something like MyModule.CConfig.SetStaticOption(...) I get (in Chrome) Uncaught TypeError: MyModule.CConfig.SetStaticOption is not a function.
I would have thought for this to work I would have needed to instantiate a CConfig option. Right?
The proposed change still works like MyModule.CConfig.prototype.SetStaticOption(...), but can now also work like MyModule.CConfig.SetStaticOption(...).
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 see, thanks, sounds good.
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 think that leaves testing - as mentioned earlier, please both both notations that work after this change.
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 updated the tests to test both access methods, but the below line (TheModule.Child2.prototype.printStatic();) seems to fail on node in test-uvwxyz. It looks like it must be throwing? I don't have any node experience, any ideas what could be going wrong?
Also this appears to have increased the number of exports by one in the test-upstream-other tests. But I'm not really sure what the significance of that is, or why my change affected that?
Any pointers?
Edit: fixed after merging in latest. No idea how that broke or was fixed.
|
cc @wingo - would be good if you can take a look here, thanks! |
|
I think the metadce test errors in I don't have any ideas about what could be wrong in the webidl test error. Does it fail for you locally when running that test? |
|
The |
Yep, just haven't got around to looking at it yet. Personally I think we should drop accessing statics like Edit: crap, just noticed I messed up the merge, I'll fix that too. |
|
@kripken I'm going to need some help understanding the failing test. It looks like the only one caused directly by me is under |
|
@VirtualTim looks like it fails on Line 7998 in ab4953c
.circleci/config.yml).
The actual building is done by It does mention the test failed on node, but that's just because it was the first JS engine to be tested, and it failed - so nothing special about node there, I'm pretty sure. (once one fails, it stops checking other JS VMs on that test) |
|
Thanks for that. I think the problem is that But I don't know why no one hasn't seen this before, or why my change caused issues. |
|
Does that PR fix the issue @VirtualTim? My guess it may be unrelated, but I could be wrong. Let me know if you need help debugging this. |
|
Sorry, haven't had much of chance to spend time on this. The RP didn't help, I think I must have had some misunderstanding abut the code the test generated. The fact that it only fails with -O2 makes me think that this isn't anything I've introduced, but I'd like to figure it out before this PR lands just to be sure. |
|
Some -O2 tests do additional things like run closure compiler - so maybe the bug here is specific to closure. Building with closure and |
I'd still like to merge this, but haven't had the time to work on it. May as well merge in incoming to keep this up to date.
|
The deletion of the |
|
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant. |
|
I still think this would be nice, but could never figure out that failing test... |
|
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant. |
|
I just merged in the latest Emscription changes to see if that changed anything. I still don't have any idea how to fix this, but maybe I'll try again in another few years. |
|
Do we still want to try and land this? |
|
Closing this for now as inactive. Feel free to re-open. |
According to the WebIDL spec static properties should be accessed like [class].[function], not [class].prototype.[function].
See: https://www.w3.org/TR/WebIDL/#idl-static-attributes-and-operations
Fixes #8705.