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

What is the motivation for the Date.prototype.toString() non-Date receiver support? #849

Closed
littledan opened this Issue Mar 17, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@littledan
Member

littledan commented Mar 17, 2017

In the spec, Date.prototype.toString falls back to "Invalid Date" when the receiver is a non-Date Object. However, apparently d8 and jsc don't implement this and throw a TypeError, both for Date.prototype and for {}. ChakraCore seems to return "Invalid Date" for Date.prototype and throw for other objects, and SpiderMonkey implements the spec properly.

What was the motivation for this path in Date.prototype.toString? Was it web compatibility? If so, it seems like we have some evidence that it could be removed. It looks like this path wasn't present in the ES 5.1 version.

littledan added a commit to littledan/ecma262 that referenced this issue Mar 18, 2017

Normative: Date.prototype.toString throws on non-Date receiver
JSC and V8 have been shipping the version of the specification
included in this patch, so it is likely to be web-compatible.
Throwing on receivers which are not Date instances is simpler
and more consistent with other methods in ECMAScript.

Closes tc39#849

littledan added a commit to littledan/test262 that referenced this issue Mar 21, 2017

littledan added a commit to littledan/test262 that referenced this issue Mar 23, 2017

bterlson added a commit that referenced this issue Jun 28, 2017

Normative: Date.prototype.toString throws on non-Date receiver (#850)
JSC and V8 have been shipping the version of the specification
included in this patch, so it is likely to be web-compatible.
Throwing on receivers which are not Date instances is simpler
and more consistent with other methods in ECMAScript.

Closes #849
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment