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

Contradiction in 20.3.4.41 Date.prototype.toString note 2 #1268

Closed
bathos opened this Issue Jul 20, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@bathos
Contributor

bathos commented Jul 20, 2018

The second note for Date.prototype.toString states:

The toString function is intentionally generic; it does not require that its this value be a Date object. Therefore, it can be transferred to other kinds of objects for use as a method.

However, the algorithm begins with this step:

Let tv be ? thisTimeValue(this value).

The thisTimeValue operation is not generic; it throws a TypeError if the receiver does not have a [[DateValue]] slot.

I believe this note is likely a mistake, unless I am misunderstanding what “generic” signifies here.

claudepache added a commit to claudepache/ecma262 that referenced this issue Jul 20, 2018

Date.porotype.toString is not generic
Date.porotype.toString is not generic.
Fixes tc39#1268

claudepache added a commit to claudepache/ecma262 that referenced this issue Jul 20, 2018

Date.prototype.toString is not generic
Date.prototype.toString is not generic.
Fixes tc39#1268

bterlson added a commit that referenced this issue Aug 2, 2018

@allenwb

This comment has been minimized.

Show comment
Hide comment
@allenwb

allenwb Aug 3, 2018

Member

Note that in ES2015 it was generic because it used NaN as the TimeValue the [[DateValue]] field was not present.

Hopefully, there was a reason that was changed and why the generic method note is out of date.

Member

allenwb commented Aug 3, 2018

Note that in ES2015 it was generic because it used NaN as the TimeValue the [[DateValue]] field was not present.

Hopefully, there was a reason that was changed and why the generic method note is out of date.

@claudepache

This comment has been minimized.

Show comment
Hide comment
@claudepache

claudepache Aug 3, 2018

Contributor

Note that in ES2015 it was generic because it used NaN as the TimeValue the [[DateValue]] field was not present.

Hopefully, there was a reason that was changed and why the generic method note is out of date.

See #850.

Here is the broader context for those that weren’t born during the heroic times of es6 standardisation: In the beginning, Date.prototype was a Date object (i.e., an object with a [[DateValue]] internal slot). At some point in time, it was made into an ordinary object. Then, Date.prototype.toString() was made generic, so that stringification of Date.prototype (included implicit one as in alert(Date.prototype)) wouldn’t accidentally throw. Finally, it was made non-generic nonetheless for reasons mentioned in PR #850.

Contributor

claudepache commented Aug 3, 2018

Note that in ES2015 it was generic because it used NaN as the TimeValue the [[DateValue]] field was not present.

Hopefully, there was a reason that was changed and why the generic method note is out of date.

See #850.

Here is the broader context for those that weren’t born during the heroic times of es6 standardisation: In the beginning, Date.prototype was a Date object (i.e., an object with a [[DateValue]] internal slot). At some point in time, it was made into an ordinary object. Then, Date.prototype.toString() was made generic, so that stringification of Date.prototype (included implicit one as in alert(Date.prototype)) wouldn’t accidentally throw. Finally, it was made non-generic nonetheless for reasons mentioned in PR #850.

@allenwb

This comment has been minimized.

Show comment
Hide comment
@allenwb

allenwb Aug 3, 2018

Member

As speculated in #850 the ES6 specification for Date.prototype.toString was indeed based upon the long and nuanced discussion at https://mail.mozilla.org/pipermail/es-discuss/2014-June/037630.html

Unfortunately, there is no indication in the May 2017 meeting notes that any of the points from that thread were presented or discussed when asking the committee to change the ES6 design.

Member

allenwb commented Aug 3, 2018

As speculated in #850 the ES6 specification for Date.prototype.toString was indeed based upon the long and nuanced discussion at https://mail.mozilla.org/pipermail/es-discuss/2014-June/037630.html

Unfortunately, there is no indication in the May 2017 meeting notes that any of the points from that thread were presented or discussed when asking the committee to change the ES6 design.

nicolo-ribaudo added a commit to nicolo-ribaudo/babel that referenced this issue Aug 13, 2018

Fix _isNaiveReflectConstruct helper
Date#toString is generic in ES2015 [1] and it doesn't throw, so we also
check Map#get (which on the other hand doesn't exist in ES5 browsers).

[1]: tc39/ecma262#1268 (comment)

nicolo-ribaudo added a commit to nicolo-ribaudo/babel that referenced this issue Aug 13, 2018

Fix _isNaiveReflectConstruct helper
Date#toString is generic in ES2015 [1] and it doesn't throw, so we also
check Map#get (which on the other hand doesn't exist in ES5 browsers).

[1]: tc39/ecma262#1268 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment