Debian Codegraph @

js/src/tests/test262/language/eval-code/direct/super-prop-expr-no-home.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-performeval
5 description: >
6 SuperProperty may may only occur in eval code for direct eval within a method
7 info: |
8 [...]
9 4. Let inMethod be false.
10 5. Let inConstructor be false.
11 6. If thisEnvRec has a [[HomeObject]] field, then
12 a. Let inMethod be true.
13 b. If thisEnvRec.[[FunctionObject]] has a [[Construct]] field, let
14 inConstructor be true.
15 7. Let script be the ECMAScript code that is the result of parsing x,
16 interpreted as UTF-16 encoded Unicode text as described in 6.1.4, for the
17 goal symbol Script. If inMethod is false, additional early error rules
18 from 18.2.1.1.1 are applied. If inConstructor is false, additional early
19 error rules from 18.2.1.1.2 are applied. If the parse fails, throw a
20 SyntaxError exception. If any early errors are detected, throw a
21 SyntaxError or a ReferenceError exception, depending on the type of the
22 error (but see also clause 16). Parsing and early error detection may be
23 interweaved in an implementation dependent manner.
24
25 18.2.1.1.1 Additional Early Error Rules for Eval Outside Methods
26
27 ScriptBody : StatementList
28
29 - It is a Syntax Error if StatementList contains super.
30 features: [super]
31 ---*/
32
33 var caught;
34 function f() {
35 // Early errors restricting the usage of SuperProperty necessitate the use of
36 // `eval`.
37 try {
38 eval('super["x"];');
39 } catch (err) {
40 caught = err;
41 }
42 }
43
44 f();
45
46 assert.sameValue(typeof caught, 'object');
47 assert.sameValue(caught.constructor, SyntaxError);
48
49 reportCompare(0, 0);