Closed
Bug 1394626
Opened 8 years ago
Closed 8 years ago
JS engine confuses undefined with empty in completion records
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
DUPLICATE
of bug 1317378
People
(Reporter: Oriol, Unassigned)
Details
Run this code: eval('1; if(0){}')
Result: 1
Expected: undefined
If I understand correctly,
1. `1;` returns a normal completion record with value `1`, let's call it `sl`.
2. `if(0){}` returns `NormalCompletion(undefined)`, let's call it `s`, according to http://www.ecma-international.org/ecma-262/8.0/#sec-if-statement-runtime-semantics-evaluation.
3. Therefore `1; if(0){}` returns `Completion(UpdateEmpty(s, sl))` according to http://www.ecma-international.org/ecma-262/8.0/#sec-block-runtime-semantics-evaluation.
4. `UpdateEmpty(s, sl)` returns `Completion(s)` because `s.[[Value]]` is not `empty` (it's `undefined`), according to http://www.ecma-international.org/ecma-262/8.0/#sec-updateempty.
It seems the JS engine thinks that `undefined` is `empty` and thus returns `Completion{[[Type]]: s.[[Type]], [[Value]]: sl, [[Target]]: s.[[Target]] }`
Edge behaves like Firefox, Chrome does it correctly.
Updated•8 years ago
|
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•