Wrong error type for arr[i]++ if arr is null and i is nonexistent, due to checking for null/undefined too soon
Categories
(Core :: JavaScript Engine, task, P3)
Tracking
()
People
(Reporter: jorendorff, Unassigned)
References
(Blocks 1 open bug, )
Details
$ es6draft
js> arr = null; arr[i]++;
uncaught exception: ReferenceError: cannot resolve reference: "i"
$ js
js> arr = null; arr[i]++;
typein:1:13 TypeError: arr is null
Which is right, TypeError or ReferenceError?
I think ReferenceError is right, and we can fix this by deleting these lines.
| Reporter | ||
Updated•6 years ago
|
| Reporter | ||
Updated•6 years ago
|
Comment 1•6 years ago
|
||
Deleting these lines should result in null[{toString(){print("hello"); return 0}}]++ printing "hello", which is also a spec violation. See bug 1286997.
I think we're still, more or less, waiting for a decision on https://github.com/tc39/ecma262/issues/467. So either all engines try to implement the specification (*) or the spec should be changed to match the engines (**).
(*) Where it's not entirely clear if the current spec should be implemented or some parts of the spec should first be changed, so it's easier to implement the reference semantics correctly.
(**) This requires to find some common ground first, because there are small differences across the engines for certain edge cases.
Updated•3 years ago
|
Description
•