Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

%ThrowTypeError%.toString() is not clearly defined #14

Closed
claudepache opened this issue Jul 29, 2016 · 4 comments
Closed

%ThrowTypeError%.toString() is not clearly defined #14

claudepache opened this issue Jul 29, 2016 · 4 comments

Comments

@claudepache
Copy link

The Function.prototype.toString() definition says:

  1. If func is (...) a built-in Function object, etc. (...) Additionally, if func is a Well-known Intrinsic Object, the portion of the returned String that would be matched by BindingIdentifier must be the initial value of the name property of func.

However, the intrinsic %ThrowTypeError% is anonymous, and ECMA262 requires the name property only for non-anonymous built-in functions (Section 17)

In implementation reality, the name property of %ThrowTypeError% varies between undefined (Chakra) and "" (SM, V8, JSC).

Possible fix: use anonymous in place of the name for anonymous function.

@claudepache
Copy link
Author

... or maybe the requirement should be only for non-anonymous well-known intrinsic objects.

@michaelficarra
Copy link
Member

I think we should just make it an invariant that all well-known intrinsics that are functions be given names. Basically, add

The value of the name property of %ThrowTypeError% is "ThrowTypeError".

to 9.2.7.1. I'll open a PR.

@michaelficarra
Copy link
Member

By the way @claudepache, how did you get a reference to this intrinsic in order to observe its name?

@claudepache
Copy link
Author

how did you get a reference to this intrinsic in order to observe its name?

var ThrowTypeError = (function() { "use strict"; return Object.getOwnPropertyDescriptor(arguments, "callee").get })()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants