blob: 88111fbaee4b94edb61ad8429da990326bbf351e [file] [log] [blame]
keith_miller@apple.combcc77f22016-07-15 06:03:25 +00001// Copyright (C) 2015 André Bargull. All rights reserved.
2// This code is governed by the BSD license found in the LICENSE file.
3
4/*---
5es6id: 18.2.1.2
6description: Throws a TypeError if a global function cannot be defined.
7info: >
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 ...
22flags: [noStrict]
23---*/
24
25var error;
26try {
27 eval("function NaN(){}");
28} catch (e) {
29 error = e;
30}
31
32assert(error instanceof TypeError);