Closed Bug 980945 Opened 10 years ago Closed 9 years ago

Typed array constructors should not work without "new" per spec

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla44
Tracking Status
firefox44 --- fixed

People

(Reporter: bzbarsky, Assigned: evilpie)

References

Details

(Keywords: dev-doc-complete, site-compat, Whiteboard: [DocArea=JS])

Attachments

(1 file)

Per current ES6 spec, this expression:

  Uint8Array()

at global scope should throw, because the this object will not be a Uint8Array object.

Currently Chrome and Safari do what the spec says.  We and IE treat it the same as "new Uint8Array()".

We should either fix this or get the spec fixed (e.g. for Array() the spec allows the variant without "new").

Note that there are extension compat problems here, by the way; the Add-On SDK has stuff like:

  return Uint8Array(TextEncoder(encoding).encode(subject).buffer);
Blocks: es6
Keywords: dev-doc-needed
Whiteboard: [DocArea=JS]
Filed bug 980962 to get our own house in order.
Depends on: 980962
(In reply to Boris Zbarsky [:bz] from comment #0)
> Note that there are extension compat problems here, by the way; the Add-On
> SDK has stuff like:
> 
>   return Uint8Array(TextEncoder(encoding).encode(subject).buffer);

this shouldn't be too big of a problem. this issue is:

a) localized to one module file (plus a unit test)
b) relatively new, "shipped" less then 3 months ago with SDK 1.15
a) in a low-level module, with lesser guarantees for stability (marked 'experimental')
c) introduced with SDK 1.15, which (by default) creates addons that use modules built into firefox

so in my estimate, fixing one file and uplifting it to firefox should not result in too big compat problems.
Depends on: 980989
Ah, didn't realize this part of the SDK was new.  Hopefully none of the addons that include that are using it, then.

Note that I plan to fix this tree-wide in bug 980962.
ah, the product/component of bug 980962 threw me off.

ok, removing dependance and renaming 980989 to our "sync up trees" bug..
No longer depends on: 980989
OS: Mac OS X → All
Hardware: x86 → All
Keywords: site-compat
Depends on: 997973
Blocks: 1062075
Depends on: 1108261
No longer blocks: es6
Chrome already requires `new`. So maybe we can do this now?
Assignee: nobody → evilpies
Depends on: 1120432
Try push https://treeherder.mozilla.org/#/jobs?repo=try&revision=14da7f820040 looks good to me. I hope we can land this without breaking the internet :)
Attachment #8673883 - Flags: review?(efaustbmo)
Comment on attachment 8673883 [details] [diff] [review]
Throw when invoking a typed array constructor without new

Review of attachment 8673883 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks!
Attachment #8673883 - Flags: review?(efaustbmo) → review+
https://hg.mozilla.org/mozilla-central/rev/31561a5ce4de
https://hg.mozilla.org/mozilla-central/rev/f7e8784f32b9
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: