Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upContradicting forbidden extensions for "caller" property on built-in functions? #867
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
claudepache
Apr 5, 2017
Contributor
Presumably, the second bullet applies to non-strict functions only.
|
Presumably, the second bullet applies to non-strict functions only. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bterlson
Apr 6, 2017
Member
I agree it seems contradictory. Additionally, IIRC built-in functions should be as strict-like as possible. Is a simple fix just removing the "or built-in function objects"?
|
I agree it seems contradictory. Additionally, IIRC built-in functions should be as strict-like as possible. Is a simple fix just removing the "or built-in function objects"? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
erights
Apr 6, 2017
Precisely speaking, there are three kinds of functions: strict, sloppy, and built-in. I know we are trying to avoid the term "sloppy" in spec language, and I do not argue for it. I agree it sounds too judgemental and informal. But "non-strict" is too misleading because built-in functions are "not strict" but not "non-strict". This is too confusing.
Regarding caller and arguments, they should only be allowed in the initial state of:
- sloppy functions
- as accessor properties of the built-in
Function.prototypewhose getters and setters only throw.
It must be disallowed in the initial state of all other built-ins and all strict functions. Once created, nothing prevents the user from defining them as normal properties on these functions, but the inherited accessor will inhibit doing so.
erights
commented
Apr 6, 2017
•
|
Precisely speaking, there are three kinds of functions: strict, sloppy, and built-in. I know we are trying to avoid the term "sloppy" in spec language, and I do not argue for it. I agree it sounds too judgemental and informal. But "non-strict" is too misleading because built-in functions are "not strict" but not "non-strict". This is too confusing. Regarding
It must be disallowed in the initial state of all other built-ins and all strict functions. Once created, nothing prevents the user from defining them as normal properties on these functions, but the inherited accessor will inhibit doing so. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
erights
Apr 6, 2017
The second bullet must not include "built-in". I don't know how that got in there.
erights
commented
Apr 6, 2017
|
The second bullet must not include "built-in". I don't know how that got in there. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bterlson
Apr 6, 2017
Member
@erights blame your Editor, probably :-P
I agree with you about tightening the terminology. But the quick fix of removing "built-in" from the 2nd bullet seems good in and of itself, right?
|
@erights blame your Editor, probably :-P I agree with you about tightening the terminology. But the quick fix of removing "built-in" from the 2nd bullet seems good in and of itself, right? |
erights
referenced this issue
Apr 6, 2017
Open
Need terminology other than "non-strict" for sloppy functions #875
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
erights
commented
Apr 6, 2017
|
@bterlson Right! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
allenwb
Apr 7, 2017
Member
Note that the categories of strict functions and builtin functions are not necessarily disjoint. According to https://tc39.github.io/ecma262/#sec-built-in-function-objects a built-in function may be implemented using a strict mode ECMAScript language function.
Also in the spec. text "ECMAScript function objects defined using syntactic constructors in strict mode code...", the word "constructors" is either an original typo or an incorrect change that has been made to the original text. It should be "constructs". That sentence was intended to be about functions objects that were defined via FunctionDeclaration, MethodDeclaration, etc. as distinct from functions defined progamatically or by extra-lingual mechanisms.
|
Note that the categories of strict functions and builtin functions are not necessarily disjoint. According to https://tc39.github.io/ecma262/#sec-built-in-function-objects a built-in function may be implemented using a strict mode ECMAScript language function. Also in the spec. text "ECMAScript function objects defined using syntactic constructors in strict mode code...", the word "constructors" is either an original typo or an incorrect change that has been made to the original text. It should be "constructs". That sentence was intended to be about functions objects that were defined via FunctionDeclaration, MethodDeclaration, etc. as distinct from functions defined progamatically or by extra-lingual mechanisms. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jmdyck
Apr 7, 2017
Collaborator
the word "constructors" is either an original typo or an incorrect change that has been made to the original text. It should be "constructs"
(The phrase "syntactic constructors" was introduced in draft rev 27 of ES6, when the "Forbidden Extensions" section was added.)
(The phrase "syntactic constructors" was introduced in draft rev 27 of ES6, when the "Forbidden Extensions" section was added.) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
anba
Apr 7, 2017
Contributor
FWIW V8 and Chakra currently create built-in functions with own "caller" and "arguments" properties.
|
FWIW V8 and Chakra currently create built-in functions with own "caller" and "arguments" properties. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
erights
Apr 7, 2017
Why? This seems like extra cost for no purpose, in addition to being non-standard.
erights
commented
Apr 7, 2017
|
Why? This seems like extra cost for no purpose, in addition to being non-standard. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
allenwb
Apr 7, 2017
Member
Ok, after spend all to much time review the terminology in the current specification, I think all we need is one additional strike-out to @anba's original suggestion:
Other than as defined in this specification,ECMAScript function objects defined using syntactic constructors in strict mode code must not be created with own properties named "caller" or "arguments"other than those that are created by applying the AddRestrictedFunctionProperties abstract operation to the function. [...]. Built-in functions, [ ...] also must not be created with such own properties.- If an implementation extends non-strict
or built-infunction objects with an own property named "caller" [...].
There is an issue about the one remaining issue of AddRestrictionFunctionProperties in the spec. that I will file a separate bug about.
Uupdate: turned "constructor" into "construct"
|
Ok, after spend all to much time review the terminology in the current specification, I think all we need is one additional strike-out to @anba's original suggestion:
There is an issue about the one remaining issue of AddRestrictionFunctionProperties in the spec. that I will file a separate bug about. Uupdate: turned "constructor" into "construct" |
allenwb
referenced this issue
Apr 7, 2017
Open
Remove the AddRestrictedFunctionProperties abstract operation #877
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
claudepache
Apr 7, 2017
Contributor
The first bullet could be simplified:
- Other than as defined in this specification, a Function object must not be created with own properties named "arguments" or "caller", unless it is a non-strict function created using the Function constructor, a FunctionDeclaration, or a FunctionExpression.
(The “Other than as defined in this specification” refers specifically to Function.prototype.{arguments,caller}; it is premature to strike it now.)
|
The first bullet could be simplified:
(The “Other than as defined in this specification” refers specifically to |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
allenwb
Apr 7, 2017
Member
@claudepache The change suggested in #877 eliminates those properties from %FunctionPrototype%. Both sets of changes should be made as a unit.
|
@claudepache The change suggested in #877 eliminates those properties from %FunctionPrototype%. Both sets of changes should be made as a unit. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
erights
commented
Apr 7, 2017
|
I do not remember any agreement to remove them from |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
allenwb
Apr 7, 2017
Member
@erights why would we explicitly need them? Function.prototype is a built-in function, so if they don't have them the forbidden extension restrictions apply.
|
@erights why would we explicitly need them? Function.prototype is a built-in function, so if they don't have them the forbidden extension restrictions apply. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
erights
Apr 7, 2017
Perhaps we do not need them. But I'm raising a procedural question: Did we agree to get rid of them? If we had, I can imagine that I may have either agreed or disagreed. Both are plausible enough. But I genuinely do not remember.
erights
commented
Apr 7, 2017
|
Perhaps we do not need them. But I'm raising a procedural question: Did we agree to get rid of them? If we had, I can imagine that I may have either agreed or disagreed. Both are plausible enough. But I genuinely do not remember. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
allenwb
Apr 7, 2017
Member
My recollection is that the basic agreement we came to during ES6 was that the poison-pill properties could be eliminated in favor of forbidden extension restrictions. I also don't recall whether we explicitly talked about %FunctionPrototype& but removing those properties from them simply seems like part of implementing that agreement. The fact that they are still there seems like an oversight.
|
My recollection is that the basic agreement we came to during ES6 was that the poison-pill properties could be eliminated in favor of forbidden extension restrictions. I also don't recall whether we explicitly talked about %FunctionPrototype& but removing those properties from them simply seems like part of implementing that agreement. The fact that they are still there seems like an oversight. |
anba commentedApr 5, 2017
From https://tc39.github.io/ecma262/#sec-forbidden-extensions:
Other than as defined in this specification,ECMAScript function objects defined using syntactic constructors in strict mode code must not be created with own properties named "caller" or "arguments"other than those that are created by applying the AddRestrictedFunctionProperties abstract operation to the function. [...]. Built-in functions, [...] also must not be created with such own properties.The first bullet point seems to disallow adding "caller" (and "arguments") to built-in functions, whereas the second bullet points adds a restriction when "caller" is present on built-in functions. This seems contradictory to me.