TI: different output with options("strict")

RESOLVED INVALID

Status

()

Core
JavaScript Engine
RESOLVED INVALID
7 years ago
7 years ago

People

(Reporter: jandem, Unassigned)

Tracking

(Blocks: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

7 years ago
--
options("strict");

function f() {
    for (var i=0; i<2; i++) {
        eval("function g() { if ([].x) return 1;}");
    }
}
f();
--
./js test.js
test.js:6: strict warning: function g does not always return a value:
test.js:6: strict warning: function g() { if ([].x) return 1;}
test.js:6: strict warning: .............^

./js -n test.js
test.js:6: strict warning: function g does not always return a value:
test.js:6: strict warning: function g() { if ([].x) return 1;}
test.js:6: strict warning: .............^
test.js:6: strict warning: function g does not always return a value:
test.js:6: strict warning: function g() { if ([].x) return 1;}
test.js:6: strict warning: .............^

Not sure if the extra strict warnings is very important, but there may be a more serious bug.
I think this is working as intended.  If inference is enabled, we look for functions defined outside of loops in global and eval scripts (checkSingletonContext) and give those functions a singleton type.  When this happens the eval script can't be reused (as reusing would use the same inner function and invalidate the singleton info), so in the second loop iteration the eval cache does not find it, we recompile and emit a new warning.
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.