diff --git a/src/class-elements/grammar-private-environment-on-class-heritage-array-literal.case b/src/class-elements/grammar-private-environment-on-class-heritage-array-literal.case new file mode 100644 index 0000000000..9b8f0412e2 --- /dev/null +++ b/src/class-elements/grammar-private-environment-on-class-heritage-array-literal.case @@ -0,0 +1,34 @@ +// Copyright (C) 2019 Caio Lima (Igalia S.L). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: It's a SyntaxError if an array literal evaluated on ClassHeritage uses a private name. +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... +template: syntax/invalid +features: [class-fields-private, class-fields-public] +---*/ + +//- heritage + +extends (o) => [o.#foo] + +//- elements + +#foo; diff --git a/src/class-elements/grammar-private-environment-on-class-heritage-chained-usage.case b/src/class-elements/grammar-private-environment-on-class-heritage-chained-usage.case new file mode 100644 index 0000000000..5a1fc91698 --- /dev/null +++ b/src/class-elements/grammar-private-environment-on-class-heritage-chained-usage.case @@ -0,0 +1,34 @@ +// Copyright (C) 2019 Caio Lima (Igalia S.L). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: It's a SyntaxError if a class expression evaluated on ClassHeritage uses an private name declared on subclass. +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... +template: syntax/invalid +features: [class-fields-private, class-fields-public] +---*/ + +//- heritage + +extends class extends class extends class { x = this.#foo; } { #foo; x = this.#ba;r } { #bar; x = this.#fuz; } + +//- elements + +#fuz; diff --git a/src/class-elements/grammar-private-environment-on-class-heritage-function-expression.case b/src/class-elements/grammar-private-environment-on-class-heritage-function-expression.case new file mode 100644 index 0000000000..34cb373be7 --- /dev/null +++ b/src/class-elements/grammar-private-environment-on-class-heritage-function-expression.case @@ -0,0 +1,34 @@ +// Copyright (C) 2019 Caio Lima (Igalia S.L). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: It's a SyntaxError if a function expression evaluated on ClassHeritage uses a private name. +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... +template: syntax/invalid +features: [class-fields-private, class-fields-public] +---*/ + +//- heritage + +extends function() { x = this.#foo; } + +//- elements + +#foo; diff --git a/src/class-elements/grammar-private-environment-on-class-heritage-obj-literal.case b/src/class-elements/grammar-private-environment-on-class-heritage-obj-literal.case new file mode 100644 index 0000000000..a4b12f3667 --- /dev/null +++ b/src/class-elements/grammar-private-environment-on-class-heritage-obj-literal.case @@ -0,0 +1,34 @@ +// Copyright (C) 2019 Caio Lima (Igalia S.L). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: It's a SyntaxError if a object literal evaluated on ClassHeritage uses a private name. +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... +template: syntax/invalid +features: [class-fields-private, class-fields-public] +---*/ + +//- heritage + +extends (o) => {x: o.#foo} + +//- elements + +#foo; diff --git a/src/class-elements/grammar-private-environment-on-class-heritage-recursive.case b/src/class-elements/grammar-private-environment-on-class-heritage-recursive.case new file mode 100644 index 0000000000..f603f3ecd7 --- /dev/null +++ b/src/class-elements/grammar-private-environment-on-class-heritage-recursive.case @@ -0,0 +1,34 @@ +// Copyright (C) 2019 Caio Lima (Igalia S.L). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: It's a SyntaxError if a class expression evaluated on ClassHeritage of a ClassHeritage uses an undeclared private name. +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... +template: syntax/invalid +features: [class-fields-private, class-fields-public] +---*/ + +//- heritage + +extends class extends class { x = this.#foo; } {} + +//- elements + +#foo; diff --git a/test/language/expressions/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-array-literal.js b/test/language/expressions/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-array-literal.js new file mode 100644 index 0000000000..8c8cbae850 --- /dev/null +++ b/test/language/expressions/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-array-literal.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-private-environment-on-class-heritage-array-literal.case +// - src/class-elements/syntax/invalid/cls-expr-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if an array literal evaluated on ClassHeritage uses a private name. (class expression) +esid: prod-ClassElement +features: [class-fields-private, class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... + +---*/ + + +$DONOTEVALUATE(); + +var C = class extends (o) => [o.#foo] +{ + #foo; +}; diff --git a/test/language/expressions/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-chained-usage.js b/test/language/expressions/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-chained-usage.js new file mode 100644 index 0000000000..ed20990a07 --- /dev/null +++ b/test/language/expressions/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-chained-usage.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-private-environment-on-class-heritage-chained-usage.case +// - src/class-elements/syntax/invalid/cls-expr-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a class expression evaluated on ClassHeritage uses an private name declared on subclass. (class expression) +esid: prod-ClassElement +features: [class-fields-private, class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... + +---*/ + + +$DONOTEVALUATE(); + +var C = class extends class extends class extends class { x = this.#foo; } { #foo; x = this.#ba;r } { #bar; x = this.#fuz; } +{ + #fuz; +}; diff --git a/test/language/expressions/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-function-expression.js b/test/language/expressions/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-function-expression.js new file mode 100644 index 0000000000..0b318fa8b5 --- /dev/null +++ b/test/language/expressions/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-function-expression.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-private-environment-on-class-heritage-function-expression.case +// - src/class-elements/syntax/invalid/cls-expr-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a function expression evaluated on ClassHeritage uses a private name. (class expression) +esid: prod-ClassElement +features: [class-fields-private, class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... + +---*/ + + +$DONOTEVALUATE(); + +var C = class extends function() { x = this.#foo; } +{ + #foo; +}; diff --git a/test/language/expressions/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-obj-literal.js b/test/language/expressions/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-obj-literal.js new file mode 100644 index 0000000000..0fcb85854a --- /dev/null +++ b/test/language/expressions/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-obj-literal.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-private-environment-on-class-heritage-obj-literal.case +// - src/class-elements/syntax/invalid/cls-expr-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a object literal evaluated on ClassHeritage uses a private name. (class expression) +esid: prod-ClassElement +features: [class-fields-private, class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... + +---*/ + + +$DONOTEVALUATE(); + +var C = class extends (o) => {x: o.#foo} +{ + #foo; +}; diff --git a/test/language/expressions/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-recursive.js b/test/language/expressions/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-recursive.js new file mode 100644 index 0000000000..07f2f31d47 --- /dev/null +++ b/test/language/expressions/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-recursive.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-private-environment-on-class-heritage-recursive.case +// - src/class-elements/syntax/invalid/cls-expr-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a class expression evaluated on ClassHeritage of a ClassHeritage uses an undeclared private name. (class expression) +esid: prod-ClassElement +features: [class-fields-private, class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... + +---*/ + + +$DONOTEVALUATE(); + +var C = class extends class extends class { x = this.#foo; } {} +{ + #foo; +}; diff --git a/test/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-array-literal.js b/test/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-array-literal.js new file mode 100644 index 0000000000..4cd066961a --- /dev/null +++ b/test/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-array-literal.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-private-environment-on-class-heritage-array-literal.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if an array literal evaluated on ClassHeritage uses a private name. (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... + +---*/ + + +$DONOTEVALUATE(); + +class C extends (o) => [o.#foo] +{ + #foo; +} diff --git a/test/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-chained-usage.js b/test/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-chained-usage.js new file mode 100644 index 0000000000..c66db86d23 --- /dev/null +++ b/test/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-chained-usage.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-private-environment-on-class-heritage-chained-usage.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a class expression evaluated on ClassHeritage uses an private name declared on subclass. (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... + +---*/ + + +$DONOTEVALUATE(); + +class C extends class extends class extends class { x = this.#foo; } { #foo; x = this.#ba;r } { #bar; x = this.#fuz; } +{ + #fuz; +} diff --git a/test/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-function-expression.js b/test/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-function-expression.js new file mode 100644 index 0000000000..22e66287ea --- /dev/null +++ b/test/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-function-expression.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-private-environment-on-class-heritage-function-expression.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a function expression evaluated on ClassHeritage uses a private name. (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... + +---*/ + + +$DONOTEVALUATE(); + +class C extends function() { x = this.#foo; } +{ + #foo; +} diff --git a/test/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-obj-literal.js b/test/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-obj-literal.js new file mode 100644 index 0000000000..3acb7b2ba3 --- /dev/null +++ b/test/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-obj-literal.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-private-environment-on-class-heritage-obj-literal.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a object literal evaluated on ClassHeritage uses a private name. (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... + +---*/ + + +$DONOTEVALUATE(); + +class C extends (o) => {x: o.#foo} +{ + #foo; +} diff --git a/test/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-recursive.js b/test/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-recursive.js new file mode 100644 index 0000000000..98ffcf5b09 --- /dev/null +++ b/test/language/statements/class/elements/syntax/early-errors/grammar-private-environment-on-class-heritage-recursive.js @@ -0,0 +1,39 @@ +// This file was procedurally generated from the following sources: +// - src/class-elements/grammar-private-environment-on-class-heritage-recursive.case +// - src/class-elements/syntax/invalid/cls-decl-elements-invalid-syntax.template +/*--- +description: It's a SyntaxError if a class expression evaluated on ClassHeritage of a ClassHeritage uses an undeclared private name. (class declaration) +esid: prod-ClassElement +features: [class-fields-private, class-fields-public, class] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + Runtime Semantics: ClassDefinitionEvaluation + + ClassTail : ClassHeritage { ClassBody } + ... + 5. Let outerPrivateEnvironment be the PrivateEnvironment of the running execution context. + 6. Let classPrivateEnvironment be NewDeclarativeEnvironment(outerPrivateEnvironment). + 7. Let classPrivateEnvRec be classPrivateEnvironment's EnvironmentRecord. + 8. If ClassBodyopt is present, then + a. For each element dn of the PrivateBoundIdentifiers of ClassBodyopt, + i. Perform classPrivateEnvRec.CreateImmutableBinding(dn, true). + 9. If ClassHeritageopt is not present, then + a. Let protoParent be the intrinsic object %ObjectPrototype%. + b. Let constructorParent be the intrinsic object %FunctionPrototype%. + 10. Else, + a. Set the running execution context's LexicalEnvironment to classScope. + b. NOTE: The running execution context's PrivateEnvironment is outerPrivateEnvironment when evaluating ClassHeritage. + ... + +---*/ + + +$DONOTEVALUATE(); + +class C extends class extends class { x = this.#foo; } {} +{ + #foo; +}