-
Notifications
You must be signed in to change notification settings - Fork 41
Throw error if specific constructors are called as plain functions #86
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
The below constructors will now throw an error if called without `new` as per their specifications: - CompressionStream - Headers - Request - Response - TextDecoder - TextEncoder - TransformStream - URL - URLSearchParams
new|
I thought this would increase the amount of passed tests from web-platform-tests but it looks like this part of the WebIDL specification wasn't being fully tested within web-platform-tests. I've made a pull-request to web-platform-tests which tests this part, if/when that gets merged I can update our version of web-platform-tests and then see how many more tests we pass 👍 |
tschneidereit
left a comment
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.
This is great, thank you!
I have two notes that should be fairly simple to address before landing this:
- I think we should apply this to Fastly-specific constructors as well
- how would you feel about introducing a
CTOR_HEADERmacro, parallel to theMETHOD_HEADERone, and using that instead?
The obvious difference is that we can't infer the name to use from __func__, but that seems ok to me.
…uctors have correct number of arguments and not called as regular functions
Oh that is a good suggestion! |
…tions or not enough arguments
tschneidereit
left a comment
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.
Thank you!
|
Oh, turns out |
Hooray for tests! 👯 |
Indeed! |
The below constructors will now throw an error if called as plain functions as per their specifications:
These constructors can now only be called via
neworReflect.constructI wasn't sure what we want to do with the Fastly specific constructors such as CacheOverride so I have left them as-is