non-definable-function-with-variable.js (1505B)
1 // Copyright (C) 2015 André Bargull. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 es6id: 18.2.1.2 6 description: Global variables are not created if conflicting function declarations were detected. 7 info: | 8 Runtime Semantics: EvalDeclarationInstantiation( body, varEnv, lexEnv, strict) 9 10 ... 11 8. For each d in varDeclarations, in reverse list order do 12 a. If d is neither a VariableDeclaration or a ForBinding, then 13 i. Assert: d is either a FunctionDeclaration or a GeneratorDeclaration. 14 ii. NOTE If there are multiple FunctionDeclarations for the same name, the last declaration is used. 15 iii. Let fn be the sole element of the BoundNames of d. 16 iv. If fn is not an element of declaredFunctionNames, then 17 1. If varEnvRec is a global Environment Record, then 18 a. Let fnDefinable be varEnvRec.CanDeclareGlobalFunction(fn). 19 b. ReturnIfAbrupt(fnDefinable). 20 c. If fnDefinable is false, throw TypeError exception. 21 ... 22 15. For each String vn in declaredVarNames, in list order do 23 a. If varEnvRec is a global Environment Record, then 24 i. Let status be varEnvRec.CreateGlobalVarBinding(vn, true). 25 ii. ReturnIfAbrupt(status). 26 ... 27 flags: [noStrict] 28 ---*/ 29 30 try { 31 eval("var shouldNotBeDefined; function NaN(){}"); 32 } catch (e) { 33 // Ignore TypeError exception. 34 } 35 36 assert.sameValue(Object.getOwnPropertyDescriptor(this, "shouldNotBeDefined"), undefined); 37 38 reportCompare(0, 0);