Found a bug in v8: class NonSpreadableArray extends Array { get [Symbol.isConcatSpreadable]() { return false; } } let a = new NonSpreadableArray(1,2,3) a.concat(a).length // => evaluates to 6, but should be 2
-
Show this thread
-
Firefox correctly creates a 2-element array in this case, but Chrome and Node incorrectly return [1,23,1,2,3].
1 reply 0 retweets 0 likesShow this thread -
Strangely, it looks like this bug was found and fixed 4 years ago: https://codereview.chromium.org/1192153002
1 reply 0 retweets 0 likesShow this thread -
And there is even a test case for it: https://codereview.chromium.org/1192153002/patch/1/10002 …
1 reply 0 retweets 0 likesShow this thread -
JavaScript: The Definitive Guide, 7th edition will say: "Unfortunately, at the time of this writing there is a bug in the V8 JavaScript engine, and the NonSpreadableArray subclass above does actually get spread by `concat()` in Node and in web browsers like Chrome that use V8."
2 replies 0 retweets 1 likeShow this thread -
-
Replying to @slightlylate @mathias
Thanks, Alex. I'd love to hear that I'm wrong about this, Mathias.
1 reply 0 retweets 1 like
Definitely a @v8js bug indeed. I’ve filed https://bugs.chromium.org/p/v8/issues/detail?id=9837 … to track this. @caitp88 do you remember the history here? +@tverwaes @_gsathya
-
-
Replying to @mathias @slightlylate and
Oops. I just filed issue #9836. Feel free to close mine as a dupe!
0 replies 0 retweets 1 likeThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.