tco-non-eval-with.js (1215B)
1 // |reftest| skip -- tail-call-optimization is not supported 2 // Copyright (C) 2017 André Bargull. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-function-calls-runtime-semantics-evaluation 7 description: > 8 Tail-call with identifier named "eval" in object environment. 9 info: | 10 12.3.4.1 Runtime Semantics: Evaluation 11 ... 12 6. If Type(ref) is Reference and IsPropertyReference(ref) is false and 13 GetReferencedName(ref) is "eval", then 14 a. If SameValue(func, %eval%) is true, then 15 ... 16 ... 17 9. Return ? EvaluateCall(func, ref, arguments, tailCall). 18 19 12.3.4.2 Runtime Semantics: EvaluateCall( func, ref, arguments, tailPosition ) 20 ... 21 7. If tailPosition is true, perform PrepareForTailCall(). 22 8. Let result be Call(func, thisValue, argList). 23 ... 24 25 flags: [noStrict] 26 features: [tail-call-optimization] 27 includes: [tcoHelper.js] 28 ---*/ 29 30 var callCount = 0; 31 32 var f, scope = {}; 33 with (scope) { 34 f = function (n) { 35 "use strict"; 36 if (n === 0) { 37 callCount += 1 38 return; 39 } 40 return eval(n - 1); 41 } 42 } 43 scope.eval = f; 44 45 f($MAX_ITERATIONS); 46 47 assert.sameValue(callCount, 1); 48 49 reportCompare(0, 0);