diff --git a/src/invalid-private-names/call-expression-bad-reference.case b/src/invalid-private-names/call-expression-bad-reference.case new file mode 100644 index 0000000000000000000000000000000000000000..3222878e058adf7d18b73c651c62da1e86b95d8e --- /dev/null +++ b/src/invalid-private-names/call-expression-bad-reference.case @@ -0,0 +1,23 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: bad reference in call expression +info: | + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. +template: default +features: [class-fields-private] +---*/ + +//- body +(() => {})().#x diff --git a/src/invalid-private-names/call-expression-this.case b/src/invalid-private-names/call-expression-this.case new file mode 100644 index 0000000000000000000000000000000000000000..acfae7d92fb113830dd58a131fb2c7db807f226f --- /dev/null +++ b/src/invalid-private-names/call-expression-this.case @@ -0,0 +1,23 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: this evaluated in call expression +info: | + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. +template: default +features: [class-fields-private] +---*/ + +//- body +(() => this)().#x diff --git a/src/invalid-private-names/default/block.template b/src/invalid-private-names/default/block.template new file mode 100644 index 0000000000000000000000000000000000000000..f6af760c03b86c59e63a31038e428b1d4bde8c7f --- /dev/null +++ b/src/invalid-private-names/default/block.template @@ -0,0 +1,26 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/block/early-errors/invalid-names- +name: > + Invalid private names should throw a SyntaxError, + block statement +esid: sec-static-semantics-early-errors +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +{ /*{ body }*/ } diff --git a/src/invalid-private-names/default/cls-decl-field-initializer-fn.template b/src/invalid-private-names/default/cls-decl-field-initializer-fn.template new file mode 100644 index 0000000000000000000000000000000000000000..b4da088fc336646897f39beb1dc33523412c1e8e --- /dev/null +++ b/src/invalid-private-names/default/cls-decl-field-initializer-fn.template @@ -0,0 +1,29 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/syntax/early-errors/invalid-names/field-init-fn- +name: > + Invalid private names should throw a SyntaxError, + function in class field initializer in class declaration +features: [class, class-fields-public] +esid: sec-static-semantics-early-errors +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + f = function() { /*{ body }*/ } +} diff --git a/src/invalid-private-names/default/cls-decl-field-initializer-heritage.template b/src/invalid-private-names/default/cls-decl-field-initializer-heritage.template new file mode 100644 index 0000000000000000000000000000000000000000..c4a22bbba41c573d04a29641b3fa8b88433a7cab --- /dev/null +++ b/src/invalid-private-names/default/cls-decl-field-initializer-heritage.template @@ -0,0 +1,44 @@ + +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/syntax/early-errors/invalid-names/fields-init-heritage- +name: > + Invalid private names should throw a SyntaxError, + class field initializer in class declaration +features: [class, class-fields-private] +esid: sec-static-semantics-early-errors +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + 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. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class Parent { + #x = 42; +} + +class C extends Parent { + f = /*{ body }*/ +} diff --git a/src/invalid-private-names/default/cls-decl-field-initializer.template b/src/invalid-private-names/default/cls-decl-field-initializer.template new file mode 100644 index 0000000000000000000000000000000000000000..7e40eced0f528c9bf9627747d3e5c57ad200163a --- /dev/null +++ b/src/invalid-private-names/default/cls-decl-field-initializer.template @@ -0,0 +1,29 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/syntax/early-errors/invalid-names/field-init- +name: > + Invalid private names should throw a SyntaxError, + class field initializer in class declaration +features: [class, class-fields-public] +esid: sec-static-semantics-early-errors +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + f = /*{ body }*/ +} diff --git a/src/invalid-private-names/default/cls-decl-inner-method.template b/src/invalid-private-names/default/cls-decl-inner-method.template new file mode 100644 index 0000000000000000000000000000000000000000..23bb2862c9511aa98a1df6bfd65941d41952d72c --- /dev/null +++ b/src/invalid-private-names/default/cls-decl-inner-method.template @@ -0,0 +1,44 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/syntax/early-errors/invalid-names/method-inner- +name: > + Invalid private names should throw a SyntaxError, + method in inner class declaration +features: [class, class-fields-private] +esid: sec-static-semantics-early-errors +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + 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. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + #x = 42; + m() { + class Inner { + z() { /*{ body }*/ } + } + } +} diff --git a/src/invalid-private-names/default/cls-decl-method-fn.template b/src/invalid-private-names/default/cls-decl-method-fn.template new file mode 100644 index 0000000000000000000000000000000000000000..f4f4ee3fb33d2ced4e38c13cff4731fefa9fab9f --- /dev/null +++ b/src/invalid-private-names/default/cls-decl-method-fn.template @@ -0,0 +1,31 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/syntax/early-errors/invalid-names/method-fn- +name: > + Invalid private names should throw a SyntaxError, + inner function in method in class declaration +features: [class] +esid: sec-static-semantics-early-errors +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + m() { + function fn() { /*{ body }*/ } + } +} diff --git a/src/invalid-private-names/default/cls-decl-method-heritage.template b/src/invalid-private-names/default/cls-decl-method-heritage.template new file mode 100644 index 0000000000000000000000000000000000000000..758909c8ada316faddc4624a01ecd32f0e8379c5 --- /dev/null +++ b/src/invalid-private-names/default/cls-decl-method-heritage.template @@ -0,0 +1,45 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/syntax/early-errors/invalid-names/method-heritage- +name: > + Invalid private names should throw a SyntaxError, + method in class declaration +features: [class, class-fields-private] +esid: sec-static-semantics-early-errors +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + 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. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class Parent { + #x = 42; +} + +class C extends Parent { + m() { + /*{ body }*/ + } +} diff --git a/src/invalid-private-names/default/cls-decl-method.template b/src/invalid-private-names/default/cls-decl-method.template new file mode 100644 index 0000000000000000000000000000000000000000..776dee46aac9bb56410e540674cb047919805ec1 --- /dev/null +++ b/src/invalid-private-names/default/cls-decl-method.template @@ -0,0 +1,29 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/syntax/early-errors/invalid-names/method- +name: > + Invalid private names should throw a SyntaxError, + method in class declaration +features: [class] +esid: sec-static-semantics-early-errors +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + m() { /*{ body }*/ } +} diff --git a/src/invalid-private-names/default/cls-decl-outter-method.template b/src/invalid-private-names/default/cls-decl-outter-method.template new file mode 100644 index 0000000000000000000000000000000000000000..d4b6a3c7cdb9bdf8c1879e75cf6abb51d7b5bae8 --- /dev/null +++ b/src/invalid-private-names/default/cls-decl-outter-method.template @@ -0,0 +1,45 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/syntax/early-errors/invalid-names/method-outter- +name: > + Invalid private names should throw a SyntaxError, + method in outter class declaration +features: [class, class-fields-private] +esid: sec-static-semantics-early-errors +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + 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. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class C { + m() { + class Outter { + #x = 42; + } + + this.#x; + } +} diff --git a/src/invalid-private-names/default/cls-expr-field-initializer-fn.template b/src/invalid-private-names/default/cls-expr-field-initializer-fn.template new file mode 100644 index 0000000000000000000000000000000000000000..8a2ad2d19c836ec8cbe96f58794ebc73f8f6fb9e --- /dev/null +++ b/src/invalid-private-names/default/cls-expr-field-initializer-fn.template @@ -0,0 +1,39 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/syntax/early-errors/invalid-names/field-init-fn- +name: > + Invalid private names should throw a SyntaxError, + function in class field initializer in class expression +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + 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. +features: [class, class-fields-public] +esid: sec-static-semantics-early-errors +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var C = class { + f = function() { /*{ body }*/ } +}; diff --git a/src/invalid-private-names/default/cls-expr-field-initializer-heritage.template b/src/invalid-private-names/default/cls-expr-field-initializer-heritage.template new file mode 100644 index 0000000000000000000000000000000000000000..d743217e6370fc5763754a67207ac002487c370c --- /dev/null +++ b/src/invalid-private-names/default/cls-expr-field-initializer-heritage.template @@ -0,0 +1,43 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/syntax/early-errors/invalid-names/field-init-heritage- +name: > + Invalid private names should throw a SyntaxError, + field initializer in inner class expression +features: [class, class-fields-private] +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + 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. +esid: sec-static-semantics-early-errors +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class Parent { + #x = 42; +} + +var C = class extends Parent { + f = /*{ body }*/ +}; diff --git a/src/invalid-private-names/default/cls-expr-field-initializer.template b/src/invalid-private-names/default/cls-expr-field-initializer.template new file mode 100644 index 0000000000000000000000000000000000000000..e49e9f331629abcda9624009a0f1542bd9e22da2 --- /dev/null +++ b/src/invalid-private-names/default/cls-expr-field-initializer.template @@ -0,0 +1,39 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/syntax/early-errors/invalid-names/field-init- +name: > + Invalid private names should throw a SyntaxError, + class field initializer in class expression +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + 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. +features: [class, class-fields-public] +esid: sec-static-semantics-early-errors +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var C = class { + f = /*{ body }*/ +}; diff --git a/src/invalid-private-names/default/cls-expr-inner-method.template b/src/invalid-private-names/default/cls-expr-inner-method.template new file mode 100644 index 0000000000000000000000000000000000000000..f0081d33104ec5326f607824516aea1b7ded9600 --- /dev/null +++ b/src/invalid-private-names/default/cls-expr-inner-method.template @@ -0,0 +1,44 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/syntax/early-errors/invalid-names/method-inner- +name: > + Invalid private names should throw a SyntaxError, + method in inner class expression +features: [class, class-fields-private] +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + 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. +esid: sec-static-semantics-early-errors +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var C = class { + #x = 42; + m() { + class Inner { + z() { /*{ body }*/ } + } + } +}; diff --git a/src/invalid-private-names/default/cls-expr-method-fn.template b/src/invalid-private-names/default/cls-expr-method-fn.template new file mode 100644 index 0000000000000000000000000000000000000000..68e7db30ddab0d17a697a06a0c990827aa9bc285 --- /dev/null +++ b/src/invalid-private-names/default/cls-expr-method-fn.template @@ -0,0 +1,41 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/syntax/early-errors/invalid-names/method-fn- +name: > + Invalid private names should throw a SyntaxError, + inner function in method in class expression +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + 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. +features: [class] +esid: sec-static-semantics-early-errors +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var C = class { + m() { + function fn() { /*{ body }*/ } + } +}; diff --git a/src/invalid-private-names/default/cls-expr-method-heritage.template b/src/invalid-private-names/default/cls-expr-method-heritage.template new file mode 100644 index 0000000000000000000000000000000000000000..a38c4532bcbc3d4b794e48023c54f12071a8258c --- /dev/null +++ b/src/invalid-private-names/default/cls-expr-method-heritage.template @@ -0,0 +1,45 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/syntax/early-errors/invalid-names/method-heritage- +name: > + Invalid private names should throw a SyntaxError, + method in inner class expression +features: [class, class-fields-private] +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + 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. +esid: sec-static-semantics-early-errors +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +class Parent { + #x = 42; +} + +var C = class extends Parent { + m() { + /*{ body }*/ + } +}; diff --git a/src/invalid-private-names/default/cls-expr-method.template b/src/invalid-private-names/default/cls-expr-method.template new file mode 100644 index 0000000000000000000000000000000000000000..25ed93ad45d37448eed0f6f00d824628301d2ef0 --- /dev/null +++ b/src/invalid-private-names/default/cls-expr-method.template @@ -0,0 +1,39 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/syntax/early-errors/invalid-names/method- +name: > + Invalid private names should throw a SyntaxError, + method in class expression +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + 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. +features: [class] +esid: sec-static-semantics-early-errors +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var C = class { + m() { /*{ body }*/ } +}; diff --git a/src/invalid-private-names/default/cls-expr-outter-method.template b/src/invalid-private-names/default/cls-expr-outter-method.template new file mode 100644 index 0000000000000000000000000000000000000000..0936f7991a278320d99e49f3413d3f4391f0db2e --- /dev/null +++ b/src/invalid-private-names/default/cls-expr-outter-method.template @@ -0,0 +1,45 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/syntax/early-errors/invalid-names/method-outter- +name: > + Invalid private names should throw a SyntaxError, + method in outter class expression +features: [class, class-fields-private] +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. + + Static Semantics: AllPrivateNamesValid + + ClassBody : ClassElementList + 1. Let newNames be the concatenation of names with PrivateBoundNames of ClassBody. + 2. Return AllPrivateNamesValid of ClassElementList with the argument newNames. + + 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. +esid: sec-static-semantics-early-errors +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var C = class { + m() { + class Outter { + #x = 42; + } + + this.#x; + } +}; diff --git a/src/invalid-private-names/default/convention.md b/src/invalid-private-names/default/convention.md new file mode 100644 index 0000000000000000000000000000000000000000..e922e88f78eada225b2fe5f3cf57595ffe59445d --- /dev/null +++ b/src/invalid-private-names/default/convention.md @@ -0,0 +1 @@ +Cases conventionally use #x as the private name reference to be flagged as invalid. diff --git a/src/invalid-private-names/default/function-decl.template b/src/invalid-private-names/default/function-decl.template new file mode 100644 index 0000000000000000000000000000000000000000..b170a2904ea13e7a7172b30d2c6d0c5a7c9387c2 --- /dev/null +++ b/src/invalid-private-names/default/function-decl.template @@ -0,0 +1,26 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/function/early-errors/invalid-names- +name: > + Invalid private names should throw a SyntaxError, + inside function declaration +esid: sec-static-semantics-early-errors +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +function fn() { /*{ body }*/ } diff --git a/src/invalid-private-names/default/function-expr.template b/src/invalid-private-names/default/function-expr.template new file mode 100644 index 0000000000000000000000000000000000000000..9a3f4e569e30bf2cdd122b06c8bf2860080d48ee --- /dev/null +++ b/src/invalid-private-names/default/function-expr.template @@ -0,0 +1,26 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/function/early-errors/invalid-names- +name: > + Invalid private names should throw a SyntaxError, + inside function expression +esid: sec-static-semantics-early-errors +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var fn = function() { /*{ body }*/ }; diff --git a/src/invalid-private-names/default/top-level-modulebody.template b/src/invalid-private-names/default/top-level-modulebody.template new file mode 100644 index 0000000000000000000000000000000000000000..ea3adb5626de668526e258c79b0a0f8ead540af3 --- /dev/null +++ b/src/invalid-private-names/default/top-level-modulebody.template @@ -0,0 +1,27 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/module-code/invalid-private-names- +name: > + Invalid private names should throw a SyntaxError, + top level of module body +esid: sec-static-semantics-early-errors +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. +negative: + phase: parse + type: SyntaxError +flags: [module] +---*/ + +$DONOTEVALUATE(); + +/*{ body }*/ diff --git a/src/invalid-private-names/default/top-level-scriptbody.template b/src/invalid-private-names/default/top-level-scriptbody.template new file mode 100644 index 0000000000000000000000000000000000000000..41d179b091f02a08b90af7c3f21b213018f95061 --- /dev/null +++ b/src/invalid-private-names/default/top-level-scriptbody.template @@ -0,0 +1,26 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/global-code/invalid-private-names- +name: > + Invalid private names should throw a SyntaxError, + top level of script body +esid: sec-static-semantics-early-errors +info: | + ScriptBody:StatementList + It is a Syntax Error if AllPrivateNamesValid of StatementList with an empty List + as an argument is false unless the source code is eval code that is being + processed by a direct eval. + + ModuleBody:ModuleItemList + It is a Syntax Error if AllPrivateNamesValid of ModuleItemList with an empty List + as an argument is false. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +/*{ body }*/ diff --git a/src/invalid-private-names/member-expression-bad-reference.case b/src/invalid-private-names/member-expression-bad-reference.case new file mode 100644 index 0000000000000000000000000000000000000000..8ba7510ed4bf00887cfd81cfe45cb4ad703a01d0 --- /dev/null +++ b/src/invalid-private-names/member-expression-bad-reference.case @@ -0,0 +1,23 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: bad reference in member expression +info: | + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. +template: default +features: [class-fields-private] +---*/ + +//- body +something.#x diff --git a/src/invalid-private-names/member-expression-this.case b/src/invalid-private-names/member-expression-this.case new file mode 100644 index 0000000000000000000000000000000000000000..e5797d916c1bdbc3253be6958510a0ce668e1730 --- /dev/null +++ b/src/invalid-private-names/member-expression-this.case @@ -0,0 +1,23 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: this reference in member expression +info: | + Static Semantics: AllPrivateNamesValid + + MemberExpression : MemberExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. + + CallExpression : CallExpression . PrivateName + + 1. If StringValue of PrivateName is in names, return true. + 2. Return false. +template: default +features: [class-fields-private] +---*/ + +//- body +this.#x