tc39 / Function-prototype-toString-revision

:fishing_pole_and_fish: ECMA-262 proposal to update Function.prototype.toString
https://tc39.github.io/Function-prototype-toString-revision
26 stars 10 forks source link

toString should specify if and when the function name is included #6

Closed ajklein closed 8 years ago

ajklein commented 8 years ago

I see the following NOTE at the bottom of the new spec:

"NOTE 2: Do we preserve function name? If so, do unnamed FDs and CDs in export default position cause problems here?"

I think the spec needs to specify this, since the presence (or lack) of function names has semantic meaning. Consider:

var x = function() { x = 42 };
eval(`(${x})`)() // does this assign to the outer x, or silently fail?

Similarly, for named expressions, including the name is important in case the function wishes to recurse.

michaelficarra commented 8 years ago

This spec is now completely outdated as of the last meeting. I will be entirely rewriting it (again) to reflect the committee's new wishes, which are to preserve a slice of source text from the beginning of the first token of the appropriate structure to the end of the last token. This should address your concern about function names. If so, please close.

edit: Resolution in TC39 meeting notes: https://github.com/tc39/tc39-notes/blob/master/es7/2016-01/2016-01-28.md#conclusionresolution

ajklein commented 8 years ago

Ah, thanks for the pointer, that indeed takes care of my concerns.