Closed Bug 1062075 Opened 10 years ago Closed 9 years ago

Throw for ES6 built-in constructors called without `new`

Categories

(Core :: JavaScript: Standard Library, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: 446240525, Unassigned)

References

(Blocks 1 open bug)

Details

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

js> Map()
({}) // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-map-iterable steps 1-2
js> Set()
({}) // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-set-iterable steps 1-2
js> WeakMap()
({}) // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-weakmap-iterable steps 1-2
js> ArrayBuffer()
({}) // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-arraybuffer-length steps 1-2
js> DataView(ArrayBuffer())
({}) // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-dataview-buffer-byteoffset-bytelength steps 1-2

According to the spec, these should all throw an exception like Promise does

devtools>Promise()
TypeError: Constructor Promise requires 'new'

The discussion thread is here: http://esdiscuss.org/topic/promise-vs-new-promise
There is bug 980945 for typed arrays specifically, but we don't yet have a tracking bug for this. Turning this into one.
Blocks: es6
Status: UNCONFIRMED → NEW
Depends on: 980945
Ever confirmed: true
Keywords: meta
Summary: New built-in constructors in ES6 cannot be called without `new` → Throw for ES6 built-in constructors called without `new`
Keywords: dev-doc-needed
Whiteboard: [DocArea=JS]
Keywords: site-compat
Depends on: 1083752
Depends on: 1108930
Depends on: 1108965
Depends on: 1142279
Depends on: 1214936
I think we are done here.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.