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

%TypedArray% constructor calling super #305

Closed
leobalter opened this Issue Jan 21, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@leobalter
Member

leobalter commented Jan 21, 2016

Previously on the ES2015, we got each of the TypedArray constructors calling the %TypedArray% super class:

22.2.4.1 TypedArray( ... argumentsList)

...
3. Let super be here.[[GetPrototypeOf]]().
... 
7. Return Construct(super, argumentsList, NewTarget).

Now (on the ES2016 draft/master branch) the TypedArray constructors are not calling the %TypedArray% superclass anymore. See #163 (comment)

22.2.4.1 TypedArray ( )

This description applies only if the TypedArray function is called with no arguments.

1. If NewTarget is undefined, throw a TypeError exception.
2. Let constructorName be the String value of the Constructor Name value specified in Table 50 for this TypedArray constructor.
3. Return ? AllocateTypedArray(constructorName, NewTarget, %TypedArrayPrototype%, 0).

And a super call is now seen at the %TypedArray% constructor:

22.2.1.1 %TypedArray%()


4. Let super be ? here.[[GetPrototypeOf]]().
5. If IsConstructor (super) is false, throw a TypeError exception.
...
7. Return ? Construct(super, argumentsList, NewTarget). 

It seems the the steps 4 and 5 are misplaced. They came from #247, it seems they might be removed or doesn't need to be placed there.

Checking %TypedArray% static methods as from and of, both call TypedArrayCreate which is safe when called from the TypedArray objects and won't need no further call on super as well.

It seems safe to say %TypedArray% might throw a TypeError on any way it's called. It does not help creating internals neither it seems necessary on the static methods.

@littledan

This comment has been minimized.

Show comment
Hide comment
@littledan

littledan Jan 21, 2016

Member

Seems like a typo in my PR that the TypedArray constructors don't call the super constructor. As for the %TypedArray% constructor, calling the super constructor was a suggestion by @allenwb , but I think you're right--this isn't needed, as %TypedArray% is a base class, and base classes don't tend to call their super constructor (even if one is dynamically added through proto chain manipulation).

Member

littledan commented Jan 21, 2016

Seems like a typo in my PR that the TypedArray constructors don't call the super constructor. As for the %TypedArray% constructor, calling the super constructor was a suggestion by @allenwb , but I think you're right--this isn't needed, as %TypedArray% is a base class, and base classes don't tend to call their super constructor (even if one is dynamically added through proto chain manipulation).

@allenwb

This comment has been minimized.

Show comment
Hide comment
@allenwb

allenwb Jan 22, 2016

Member

See what I said in #163 (comment) and #163 (comment) .

%TypedArray% should throw if directly newed, super called, or called. It should just throw a TypeError

Member

allenwb commented Jan 22, 2016

See what I said in #163 (comment) and #163 (comment) .

%TypedArray% should throw if directly newed, super called, or called. It should just throw a TypeError

littledan added a commit to littledan/ecma262 that referenced this issue Jan 22, 2016

littledan added a commit to littledan/ecma262 that referenced this issue Jan 22, 2016

@littledan

This comment has been minimized.

Show comment
Hide comment
@littledan

littledan Jan 22, 2016

Member

@allenwb I really like this idea. Wrote a PR to implement it. What do you think?

Member

littledan commented Jan 22, 2016

@allenwb I really like this idea. Wrote a PR to implement it. What do you think?

leobalter added a commit to leobalter/ecma262 that referenced this issue Jan 22, 2016

@leobalter

This comment has been minimized.

Show comment
Hide comment
@leobalter

leobalter Jan 22, 2016

Member

@littledan I came in 5 minutes late: 9c10da5 :)

Member

leobalter commented Jan 22, 2016

@littledan I came in 5 minutes late: 9c10da5 :)

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