Skip to content

Commit a25df66

Browse files
mikesamuelljharb
authored andcommitted
Normative: eval(nonString) should not have observable side effects (#1504)
Fixes #1495 which identifies the ordering of host callouts and input type checks as a spec bug. This uses option 1 from #1495 (comment) to ensure that type checks happen before host callouts. This can't be tested in test262 but if this lands, I will follow up with tests via web-platform-tests/wpt.
1 parent 05c7620 commit a25df66

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

spec.html

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12569,13 +12569,12 @@ <h1>Runtime Semantics: Evaluation</h1>
1256912569
1. Let _evalText_ be the first element of _argList_.
1257012570
1. If the source code matching this |CallExpression| is strict mode code, let _strictCaller_ be *true*. Otherwise let _strictCaller_ be *false*.
1257112571
1. Let _evalRealm_ be the current Realm Record.
12572-
1. Perform ? HostEnsureCanCompileStrings(_evalRealm_, _evalRealm_).
1257312572
1. Return ? PerformEval(_evalText_, _evalRealm_, _strictCaller_, *true*).
1257412573
1. Let _thisCall_ be this |CallExpression|.
1257512574
1. Let _tailCall_ be IsInTailPosition(_thisCall_).
1257612575
1. Return ? EvaluateCall(_func_, _ref_, _arguments_, _tailCall_).
1257712576
</emu-alg>
12578-
<p>A |CallExpression| evaluation that executes step 6.a.vii is a <dfn>direct eval</dfn>.</p>
12577+
<p>A |CallExpression| evaluation that executes step 6.a.vi is a <dfn>direct eval</dfn>.</p>
1257912578
<emu-grammar>CallExpression : CallExpression Arguments</emu-grammar>
1258012579
<emu-alg>
1258112580
1. Let _ref_ be the result of evaluating |CallExpression|.
@@ -23417,17 +23416,17 @@ <h1>eval ( _x_ )</h1>
2341723416
1. Assert: The execution context stack has at least two elements.
2341823417
1. Let _callerContext_ be the second to top element of the execution context stack.
2341923418
1. Let _callerRealm_ be _callerContext_'s Realm.
23420-
1. Let _calleeRealm_ be the current Realm Record.
23421-
1. Perform ? HostEnsureCanCompileStrings(_callerRealm_, _calleeRealm_).
23422-
1. Return ? PerformEval(_x_, _calleeRealm_, *false*, *false*).
23419+
1. Return ? PerformEval(_x_, _callerRealm_, *false*, *false*).
2342323420
</emu-alg>
2342423421

2342523422
<emu-clause id="sec-performeval" aoid="PerformEval">
23426-
<h1>Runtime Semantics: PerformEval ( _x_, _evalRealm_, _strictCaller_, _direct_ )</h1>
23427-
<p>The abstract operation PerformEval with arguments _x_, _evalRealm_, _strictCaller_, and _direct_ performs the following steps:</p>
23423+
<h1>Runtime Semantics: PerformEval ( _x_, _callerRealm_, _strictCaller_, _direct_ )</h1>
23424+
<p>The abstract operation PerformEval with arguments _x_, _callerRealm_, _strictCaller_, and _direct_ performs the following steps:</p>
2342823425
<emu-alg>
2342923426
1. Assert: If _direct_ is *false*, then _strictCaller_ is also *false*.
2343023427
1. If Type(_x_) is not String, return _x_.
23428+
1. Let _evalRealm_ be the current Realm Record.
23429+
1. Perform ? HostEnsureCanCompileStrings(_callerRealm_, _evalRealm_).
2343123430
1. Let _thisEnvRec_ be ! GetThisEnvironment().
2343223431
1. If _thisEnvRec_ is a function Environment Record, then
2343323432
1. Let _F_ be _thisEnvRec_.[[FunctionObject]].

0 commit comments

Comments
 (0)