Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / language / module-code / privatename-valid-no-earlyerr.js
bloba9b3c121d64b9a04072dc242118edd77a0134a2b
1 // |reftest| module
2 // Copyright (C) 2017 Valerie Young. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 esid: sec-module-semantics-static-semantics-early-errors
6 description: Referencing privatename in class within class does not error.
7 info: |
8   Static Semantics: Early Errors
9   Module : ModuleBody
10     It is a Syntax Error if AllPrivateNamesValid of ModuleBody with an empty List as an argument is false.
12   Static Semantics: AllPrivateNamesValid
13   AllPrivateNamesValid is an abstract operation which takes names as an argument.
15     MemberExpression : MemberExpression . PrivateName
16       1. If StringValue of PrivateName is in names, return true.
17       2. Return false.
19     CallExpression : CallExpression . PrivateName
20       1. If StringValue of PrivateName is in names, return true.
21       2. Return false.
23     ClassBody:ClassElementList
24       1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody.
25       2.Return AllPrivateNamesValid of ClassElementList with the argument newNames.
27     For all other grammatical productions, recurse on subexpressions/substatements, passing in the names of the caller. If all pieces return true, then return true. If any returns false, return false.
28 flags: [module]
29 features: [class, class-fields-private]
30 ---*/
32 class outer {
33   #x = 42;
35   f() {
36     var self = this;
37     return class inner {
38       g() {
39         return self.#x;
40       }
41     }
42   }
45 var innerclass = new outer().f();
46 var test = new innerclass().g();
48 assert.sameValue(test, 42);
50 reportCompare(0, 0);