Details
-
Task
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.8
-
None
Description
The compiler seems to generate unreachable byte code (discovered while working on the unreachable code warning from QTBUG-129307) in certain cases.
For example:
function f() { return; let a = 1; }
generates
=== Bytecode for "f" strict mode false register count 8 implicit return false 5 0: 0e LoadUndefined 1: 02 Ret 7 2: 0e LoadUndefined // This shouldn't be here 3: 02 Ret // This shouldn't be here
or
function f() { for (x in a) { return; } }
generates
=== Bytecode for "f" strict mode false register count 9 implicit return false 5 0: 2e 00 LoadQmlContextPropertyLookup 0 2: d6 00 GetIterator 0 4: 18 07 StoreReg r1 6: 16 07 LoadReg r1 8: d8 08 09 IteratorNext r2, 20 11: 16 08 LoadReg r2 13: 30 05 StoreNameSloppy 5 15: 0e LoadUndefined 16: 02 Ret 17: 56 CheckException // why do we do stuff after a Ret? 18: 4c f2 Jump 6. // never executed 6 20: 16 06 LoadReg r0 // never executed 22: 02 Ret // never executed