Skip to content

Commit b625829

Browse files
woessgilles-duboscq
authored andcommitted
[GR-41406] Fix eval in with statement.
1 parent 4792d4f commit b625829

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

graal-js/src/com.oracle.truffle.js.parser/src/com/oracle/truffle/js/parser/GraalJSTranslator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3656,8 +3656,9 @@ public JavaScriptNode enterWithNode(com.oracle.js.parser.ir.WithNode withNode) {
36563656
if (context.isOptionDisableWith()) {
36573657
throw Errors.createSyntaxError("with statement is disabled.");
36583658
}
3659-
// Store with object in synthetic block environment that can be captured by closures.
3660-
Environment withParentEnv = lc.getCurrentFunction().hasClosures() ? new BlockEnvironment(environment, factory, context) : environment;
3659+
// Store with object in synthetic block environment that can be captured by closures/eval.
3660+
FunctionNode function = lc.getCurrentFunction();
3661+
Environment withParentEnv = (function.hasClosures() || function.hasEval()) ? new BlockEnvironment(environment, factory, context) : environment;
36613662
try (EnvironmentCloseable withParent = new EnvironmentCloseable(withParentEnv)) {
36623663
JavaScriptNode withExpression = transform(withNode.getExpression());
36633664
JavaScriptNode toObject = factory.createToObjectFromWith(context, withExpression, true);

0 commit comments

Comments
 (0)