It evaluates and returns the value of the scoped variable x.
However, once we alter this example only slightly, x will not be in the scope of the evaluation:
(() => {
let x = 42;
return (void 0, eval)('x')
})()
Inserting this SequenceExpression causes the following error:
Error: x is not defined
Evaluating workspacejs:09f31940-1ac0-43c1-bce8-132469645c6c/lively-kernel.org/lively4/aexpr/unnamed_module_9dd25e73_9d6f_4e56_b07c_398481bb3c5f
Loading workspacejs:09f31940-1ac0-43c1-bce8-132469645c6c/lively-kernel.org/lively4/aexpr/unnamed_module_9dd25e73_9d6f_4e56_b07c_398481bb3c5f
Note, that we can still evaluate code not related to locally scoped variables:
(() => {
let x = 42;
return (void 0, eval)('window')
})()
Not only a SequenceExpression breaks scope lookup; same goes for assigning eval to a local variable:
(() => {
let x = 42;
let ev = self.eval
return ev('x')
})()
My current assumption is that the concrete syntax (the CallExpressioneval(code)) makes the local scope available in the evaluated code.
We may mitigate this issue related to Active Expressions by not rewriting a global assess to the eval function.
Consider the following code as running example:
It evaluates and returns the value of the scoped variable
x
.However, once we alter this example only slightly,
x
will not be in the scope of the evaluation:Inserting this SequenceExpression causes the following error:
Note, that we can still evaluate code not related to locally scoped variables:
Not only a SequenceExpression breaks scope lookup; same goes for assigning
eval
to a local variable:My current assumption is that the concrete syntax (the CallExpression
eval(code)
) makes the local scope available in the evaluated code.We may mitigate this issue related to Active Expressions by not rewriting a global assess to the
eval
function.