From 1d8316cb3a372eacad89e133a4ed23d667c08f9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Wed, 30 Jan 2019 06:44:10 -0800 Subject: [PATCH 1/3] Remove invalid private name templates Inner classes have access to outer private names. Fixes #2039 --- .../default/cls-decl-inner-method.template | 44 ------------------- .../default/cls-expr-inner-method.template | 44 ------------------- 2 files changed, 88 deletions(-) delete mode 100644 src/invalid-private-names/default/cls-decl-inner-method.template delete mode 100644 src/invalid-private-names/default/cls-expr-inner-method.template diff --git a/src/invalid-private-names/default/cls-decl-inner-method.template b/src/invalid-private-names/default/cls-decl-inner-method.template deleted file mode 100644 index 285973029e..0000000000 --- a/src/invalid-private-names/default/cls-decl-inner-method.template +++ /dev/null @@ -1,44 +0,0 @@ -// 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/elements/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-expr-inner-method.template b/src/invalid-private-names/default/cls-expr-inner-method.template deleted file mode 100644 index afe21203a0..0000000000 --- a/src/invalid-private-names/default/cls-expr-inner-method.template +++ /dev/null @@ -1,44 +0,0 @@ -// 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/elements/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 }*/ } - } - } -}; From 3c811642662dd79448f40ca828b0d5aeffe5bec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Wed, 30 Jan 2019 06:51:16 -0800 Subject: [PATCH 2/3] Regenerate tests --- ...hod-inner-call-expression-bad-reference.js | 57 ------------------- .../method-inner-call-expression-this.js | 57 ------------------- ...d-inner-member-expression-bad-reference.js | 57 ------------------- .../method-inner-member-expression-this.js | 57 ------------------- ...hod-inner-call-expression-bad-reference.js | 57 ------------------- .../method-inner-call-expression-this.js | 57 ------------------- ...d-inner-member-expression-bad-reference.js | 57 ------------------- .../method-inner-member-expression-this.js | 57 ------------------- 8 files changed, 456 deletions(-) delete mode 100644 test/language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-bad-reference.js delete mode 100644 test/language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-this.js delete mode 100644 test/language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-bad-reference.js delete mode 100644 test/language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-this.js delete mode 100644 test/language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-bad-reference.js delete mode 100644 test/language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-this.js delete mode 100644 test/language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-bad-reference.js delete mode 100644 test/language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-this.js diff --git a/test/language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-bad-reference.js b/test/language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-bad-reference.js deleted file mode 100644 index eaa9f0a47a..0000000000 --- a/test/language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-bad-reference.js +++ /dev/null @@ -1,57 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/invalid-private-names/call-expression-bad-reference.case -// - src/invalid-private-names/default/cls-expr-inner-method.template -/*--- -description: bad reference in call expression (Invalid private names should throw a SyntaxError, method in inner class expression) -esid: sec-static-semantics-early-errors -features: [class-fields-private, class] -flags: [generated] -negative: - phase: parse - type: SyntaxError -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. - - - 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. - ----*/ - - -$DONOTEVALUATE(); - -var C = class { - #x = 42; - m() { - class Inner { - z() { (() => {})().#x } - } - } -}; diff --git a/test/language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-this.js b/test/language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-this.js deleted file mode 100644 index 75e392e56d..0000000000 --- a/test/language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-this.js +++ /dev/null @@ -1,57 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/invalid-private-names/call-expression-this.case -// - src/invalid-private-names/default/cls-expr-inner-method.template -/*--- -description: this evaluated in call expression (Invalid private names should throw a SyntaxError, method in inner class expression) -esid: sec-static-semantics-early-errors -features: [class-fields-private, class] -flags: [generated] -negative: - phase: parse - type: SyntaxError -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. - - - 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. - ----*/ - - -$DONOTEVALUATE(); - -var C = class { - #x = 42; - m() { - class Inner { - z() { (() => this)().#x } - } - } -}; diff --git a/test/language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-bad-reference.js b/test/language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-bad-reference.js deleted file mode 100644 index 5d6af39f83..0000000000 --- a/test/language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-bad-reference.js +++ /dev/null @@ -1,57 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/invalid-private-names/member-expression-bad-reference.case -// - src/invalid-private-names/default/cls-expr-inner-method.template -/*--- -description: bad reference in member expression (Invalid private names should throw a SyntaxError, method in inner class expression) -esid: sec-static-semantics-early-errors -features: [class-fields-private, class] -flags: [generated] -negative: - phase: parse - type: SyntaxError -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. - - - 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. - ----*/ - - -$DONOTEVALUATE(); - -var C = class { - #x = 42; - m() { - class Inner { - z() { something.#x } - } - } -}; diff --git a/test/language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-this.js b/test/language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-this.js deleted file mode 100644 index 22734ed775..0000000000 --- a/test/language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-this.js +++ /dev/null @@ -1,57 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/invalid-private-names/member-expression-this.case -// - src/invalid-private-names/default/cls-expr-inner-method.template -/*--- -description: this reference in member expression (Invalid private names should throw a SyntaxError, method in inner class expression) -esid: sec-static-semantics-early-errors -features: [class-fields-private, class] -flags: [generated] -negative: - phase: parse - type: SyntaxError -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. - - - 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. - ----*/ - - -$DONOTEVALUATE(); - -var C = class { - #x = 42; - m() { - class Inner { - z() { this.#x } - } - } -}; diff --git a/test/language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-bad-reference.js b/test/language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-bad-reference.js deleted file mode 100644 index 8f8277bb1b..0000000000 --- a/test/language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-bad-reference.js +++ /dev/null @@ -1,57 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/invalid-private-names/call-expression-bad-reference.case -// - src/invalid-private-names/default/cls-decl-inner-method.template -/*--- -description: bad reference in call expression (Invalid private names should throw a SyntaxError, method in inner class declaration) -esid: sec-static-semantics-early-errors -features: [class-fields-private, class] -flags: [generated] -negative: - phase: parse - type: SyntaxError -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. - - - 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. - ----*/ - - -$DONOTEVALUATE(); - -class C { - #x = 42; - m() { - class Inner { - z() { (() => {})().#x } - } - } -} diff --git a/test/language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-this.js b/test/language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-this.js deleted file mode 100644 index f97faa1c65..0000000000 --- a/test/language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-this.js +++ /dev/null @@ -1,57 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/invalid-private-names/call-expression-this.case -// - src/invalid-private-names/default/cls-decl-inner-method.template -/*--- -description: this evaluated in call expression (Invalid private names should throw a SyntaxError, method in inner class declaration) -esid: sec-static-semantics-early-errors -features: [class-fields-private, class] -flags: [generated] -negative: - phase: parse - type: SyntaxError -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. - - - 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. - ----*/ - - -$DONOTEVALUATE(); - -class C { - #x = 42; - m() { - class Inner { - z() { (() => this)().#x } - } - } -} diff --git a/test/language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-bad-reference.js b/test/language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-bad-reference.js deleted file mode 100644 index 58db4909b1..0000000000 --- a/test/language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-bad-reference.js +++ /dev/null @@ -1,57 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/invalid-private-names/member-expression-bad-reference.case -// - src/invalid-private-names/default/cls-decl-inner-method.template -/*--- -description: bad reference in member expression (Invalid private names should throw a SyntaxError, method in inner class declaration) -esid: sec-static-semantics-early-errors -features: [class-fields-private, class] -flags: [generated] -negative: - phase: parse - type: SyntaxError -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. - - - 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. - ----*/ - - -$DONOTEVALUATE(); - -class C { - #x = 42; - m() { - class Inner { - z() { something.#x } - } - } -} diff --git a/test/language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-this.js b/test/language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-this.js deleted file mode 100644 index 820cc19245..0000000000 --- a/test/language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-this.js +++ /dev/null @@ -1,57 +0,0 @@ -// This file was procedurally generated from the following sources: -// - src/invalid-private-names/member-expression-this.case -// - src/invalid-private-names/default/cls-decl-inner-method.template -/*--- -description: this reference in member expression (Invalid private names should throw a SyntaxError, method in inner class declaration) -esid: sec-static-semantics-early-errors -features: [class-fields-private, class] -flags: [generated] -negative: - phase: parse - type: SyntaxError -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. - - - 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. - ----*/ - - -$DONOTEVALUATE(); - -class C { - #x = 42; - m() { - class Inner { - z() { this.#x } - } - } -} From b11def3bf499aa209a6e575c287182e81a38d44b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Wed, 30 Jan 2019 06:53:46 -0800 Subject: [PATCH 3/3] Global 'arguments' binding is not present in all runtime environments --- .../expressions/postfix-decrement/arguments-nostrict.js | 4 +++- .../expressions/postfix-increment/arguments-nostrict.js | 4 +++- .../expressions/prefix-decrement/arguments-nostrict.js | 4 +++- .../expressions/prefix-increment/arguments-nostrict.js | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/test/language/expressions/postfix-decrement/arguments-nostrict.js b/test/language/expressions/postfix-decrement/arguments-nostrict.js index b0b853549f..bc20c7d487 100644 --- a/test/language/expressions/postfix-decrement/arguments-nostrict.js +++ b/test/language/expressions/postfix-decrement/arguments-nostrict.js @@ -22,4 +22,6 @@ info: | flags: [noStrict] ---*/ -arguments--; +if (false) { + arguments--; +} diff --git a/test/language/expressions/postfix-increment/arguments-nostrict.js b/test/language/expressions/postfix-increment/arguments-nostrict.js index 687a6b919f..8a330bfbf1 100644 --- a/test/language/expressions/postfix-increment/arguments-nostrict.js +++ b/test/language/expressions/postfix-increment/arguments-nostrict.js @@ -22,4 +22,6 @@ info: | flags: [noStrict] ---*/ -arguments++; +if (false) { + arguments++; +} diff --git a/test/language/expressions/prefix-decrement/arguments-nostrict.js b/test/language/expressions/prefix-decrement/arguments-nostrict.js index b35bbcf51a..46b8427d9b 100644 --- a/test/language/expressions/prefix-decrement/arguments-nostrict.js +++ b/test/language/expressions/prefix-decrement/arguments-nostrict.js @@ -22,4 +22,6 @@ info: | flags: [noStrict] ---*/ ---arguments; +if (false) { + --arguments; +} diff --git a/test/language/expressions/prefix-increment/arguments-nostrict.js b/test/language/expressions/prefix-increment/arguments-nostrict.js index 557fe91383..a7f24bcc33 100644 --- a/test/language/expressions/prefix-increment/arguments-nostrict.js +++ b/test/language/expressions/prefix-increment/arguments-nostrict.js @@ -22,4 +22,6 @@ info: | flags: [noStrict] ---*/ -++arguments; +if (false) { + ++arguments; +}