-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Don't recurse in typed array constructor #269
Conversation
The recursion happens in this case: class MyInt8 extends Int8Array {
constructor(...args) {
print("MyInt8 called with:", args);
super(...args);
}
}
// Prints:
// MyInt8 called with: 1,2,3
// MyInt8 called with: 3
new MyInt8([1, 2, 3]); |
</emu-alg> | ||
|
||
<!-- es6num="22.2.2.1.1" --> | ||
<emu-clause id="sec-typedarrayfrom" aoid="TypedArrayFrom"> | ||
<h1>Runtime Semantics: TypedArrayFrom( _constructor_, _items_, _mapfn_, _thisArg_ )</h1> | ||
<p>When the TypedArrayFrom abstract operation is called with arguments _constructor_, _items_, _mapfn_, and _thisArg_, the following steps are taken:</p> | ||
<h1>Runtime Semantics: TypedArrayFrom( _O_, _constructor_, _items_, _mapfn_, _thisArg_ )</h1> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The signature of this AO is a bit strange now, since you either pass the first argument or the second. Is there some refactoring that needs to be done to clean this up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just reintroduced the strangeness. 😛
(A similar signature was present in ES6 rev24-rev30, except the O and constructor parameters are switched now.)
Let me think about this a bit, maybe it can be improved...
The various ways of creating TAs are getting hard to follow. Perhaps a high level overview of the available AOs and how/when to use them is in order? |
Added two new commits:
|
07b8b99
to
3e33231
Compare
WDYT about changing TypedArrayCreate and TypedArraySpeciesCreate to accept an optional minimumLength parameter and use that one instead of the "If argumentList is a List of a single Number, ..." condition in TypedArrayCreate? Will this improve the current situation?
|
@anba this change looks great. Really good catch on the mistakenly added recursiveness and I think the refactorings you've made help clarify this text a lot. I am also a little uncomofrtable with the "List of a single Number" step but I don't feel strongly enough about it that I think we should add an additional parameter (and pass it appropriately for (admittedly few) calls) to avoid it. That said, I leave it up to you if you want to add it. |
I also rebased this with latest master. There were some conflicts. If you would like to review this, the commit is here: bterlson@eadbf0b. |
Thanks!
That's also my opinion on this. So let's just defer this change for now.
Looks good, except a pre-existing bug in my PR (step 4 in sec-typedarray-buffer-byteoffset-length has |
No description provided.