-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
NativeError.prototype.toString? #1794
Comments
The spec would say it should be 3. Are there test262 tests that cover this at all? As for changing it, i suspect it would be easily web compatible for the 2s to change to 3s, which would be better, but I’m slightly less confident about the 2s and 3s changing to 1s. |
it appears that what V8 has rn was an accident (introduced in v8/v8@9211dee), I'll open a CL to change it and hopefully it will be accepted. I also couldn't find any test262 tests covering this. |
Sounds like the first step is to make test262 tests to cover what the spec says. |
I figured the reason there weren’t tests was that it’s not a conformance issue for these other properties to exist from 262’s perspective. That is, even though intuitively we can tell that this divergence was unlikely to have been intentional, I thought checking this was outside the scope of test262 due to
|
I think that's technically true, but i don't personally think this divergence is in the spirit of that loophope. |
cc @schuay re: v8/v8@9211dee |
I also opened https://bugs.webkit.org/show_bug.cgi?id=204629 |
3 is what the spec. has said going all the way back to ES3. This specified behavior was reviewed and confirmed during ES5 development Even though there there was considerable variation of the actual placement of properties among implementations at that time (ie, 2008) only one change was made to the specification. The initial value of NativeError.prototype.message was respecified to be the empty string. In ES3 it had been specified as "implementation defined". However, it appears that the ES5 change did miss something. In ES3 the first paragraph in the "NativeError Objct Structure" clause ended with:
The "implementation-defined" adjective should have been removed when the ES5 change was made. It wasn't and that incorrect text remains in the working draft. It should be removed. |
To summarize my interpretation of the state of this issue:
Thoughts? |
In 5742da0, the toString property was accidentally applied to all NativeError prototypes, when it should only be inherited from Error.prototype. Refs: tc39/ecma262#1794 Bug: v8:10017 Change-Id: I2af9a31f463deb9871dd7a4a5a2e4dd7485ed38c Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1933054 Reviewed-by: Adam Klein <adamk@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Commit-Queue: Adam Klein <adamk@chromium.org> Cr-Commit-Position: refs/heads/master@{#65355}
As of the latest V8 and WebKit revisions (Chrome and Safari releases notwithstanding) the chart should now be 3s everywhere. |
^ chakra still has this bug, but its not in any browser |
Has an issue been filed on ChakraCore? |
https://bugs.webkit.org/show_bug.cgi?id=204629 Patch by Gus Caplan <me@gus.host> on 2020-01-20 Reviewed by Ross Kirsling. NativeError prototypes are expected to inherit toString from Error.prototype. See tc39/ecma262#1794 for additional details. JSTests: * stress/nativeerror-prototype-tostring.js: Source/JavaScriptCore: * runtime/ErrorPrototype.cpp: (JSC::ErrorPrototypeBase::ErrorPrototypeBase): (JSC::ErrorPrototypeBase::finishCreation): (JSC::ErrorPrototype::ErrorPrototype): (JSC::ErrorPrototype::create): Deleted. (JSC::ErrorPrototype::finishCreation): Deleted. * runtime/ErrorPrototype.h: (JSC::ErrorPrototype::createStructure): Deleted. * runtime/NativeErrorPrototype.cpp: (JSC::NativeErrorPrototype::NativeErrorPrototype): * runtime/NativeErrorPrototype.h: LayoutTests: * http/tests/security/regress-52192-expected.txt: * http/tests/security/regress-52192.html: Canonical link: https://commits.webkit.org/219579@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254842 268f45cc-cd09-0410-ab3c-d52691b4dbfc
This seems to have been long fixed everywhere :) |
I believe that Firefox is correct and that none of these properties ought to exist:
EvalError.prototype.toString
RangeError.prototype.toString
ReferenceError.prototype.toString
SyntaxError.prototype.toString
TypeError.prototype.toString
URIError.prototype.toString
WebAssembly.CompileError.prototype.toString
WebAssembly.LinkError.prototype.toString
WebAssembly.RuntimeError.prototype.toString
toString
is an own data property, and its value is the same asError.protototype.toString
toString
is an own data property, and its value is a unique functiontoString
is not present (but is inherited fromError.prototype
)I included WebAssembly errors above because they’re defined in terms of the ‘NativeError Object Structure’ and because they’re interesting due to being outlying cases in Safari.
Probably none of these results are technically implementation errors because implementations are permitted to add additional properties. But it seems likely that these differences aren’t intentional, and they’re a fairly weird/seemingly pointless spot to diverge.
If somebody can confirm which of these aren’t correct, I’ll open issues in the appropriate places. I didn’t turn up any existing reports.
The text was updated successfully, but these errors were encountered: