Closed
Bug 545326
Opened 14 years ago
Closed 14 years ago
"use strict" doesn't seem to inherit into "new Function"
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
INVALID
People
(Reporter: jruderman, Assigned: Waldo)
Details
(Keywords: testcase)
js> "use strict"; new Function("with(x) {}"); (function anonymous() {with (x) {}}) js> "use strict"; (function anonymous() {with (x) {}}) typein:5: SyntaxError: strict mode code may not contain 'with' statements: typein:5: "use strict"; (function anonymous() {with (x) {}}) typein:5: .....................................^ This confuses jsfunfuzz. Is it intentional?
Assignee | ||
Comment 1•14 years ago
|
||
Nope, bug. Also note the similar situation with eval does properly result in a SyntaxError.
Assignee: general → jwalden+bmo
OS: Mac OS X → All
Hardware: x86 → All
Assignee | ||
Comment 2•14 years ago
|
||
Er, I'm wrong. 10.1.1 says the function dynamically created when |Function| is called is strict mode if it begins with a strict-mode directive, and it doesn't mention inheriting from the caller. I guess this makes sense, given that Function creates a function that has no relation to the calling environment (it's scoped globally, not locally). Nevertheless, I'm still surprised, and I really had thought semantics were supposed to be different on this point. I can't find any obvious mailing list traffic concerning this decision, so it's plausibly a spec bug. I'll send a query tomorrow.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → INVALID
Assignee | ||
Comment 3•14 years ago
|
||
Further on the global/local scoping bit, consider this, which produces 2: javascript:var a=2;function c(){var a=3;return Function("return a");}; c()()
You need to log in
before you can comment on or make changes to this bug.
Description
•