privatename-valid-no-earlyerr.js (1371B)
1 // Copyright (C) 2017 Valerie Young. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-all-private-names-valid 5 description: Referencing privatename in class within class does not error. 6 info: | 7 Static Semantics: AllPrivateNamesValid 8 9 AllPrivateNamesValid is an abstract operation which takes names as an argument. 10 11 MemberExpression : MemberExpression . PrivateName 12 1. If StringValue of PrivateName is in names, return true. 13 2. Return false. 14 15 CallExpression : CallExpression . PrivateName 16 1. If StringValue of PrivateName is in names, return true. 17 2. Return false. 18 19 ClassBody : ClassElementList 20 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. 21 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. 22 23 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. 24 25 features: [class, class-fields-private] 26 ---*/ 27 28 class outer { 29 #x = 42; 30 31 f() { 32 var self = this; 33 return class inner { 34 g() { 35 return self.#x; 36 } 37 } 38 } 39 } 40 41 var innerclass = new outer().f(); 42 var test = new innerclass().g(); 43 44 assert.sameValue(test, 42); 45 46 reportCompare(0, 0);