Assert early error for private names in method definitions

This commit is contained in:
Leo Balter 2018-11-26 19:28:05 -05:00 committed by Rick Waldron
parent 79fd1b2c76
commit 92a585f04a
12 changed files with 300 additions and 0 deletions

View File

@ -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.
/*---
esid: sec-method-definitions-static-semantics-early-errors
description: >
Throws an early SyntaxError if a method definition has a private name even
inside a class body (async method).
info: |
Static Semantics: Early Errors
PropertyDefinition : MethodDefinition
It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty.
negative:
phase: parse
type: SyntaxError
features: [class-methods-private, async-functions, class, class-fields-public]
---*/
$DONOTEVALUATE();
class C {
field = {
async #m() {}
}
}

View File

@ -0,0 +1,24 @@
// Copyright (C) 2018 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-method-definitions-static-semantics-early-errors
description: >
Throws an early SyntaxError if a method definition has a private name
(async method).
info: |
Static Semantics: Early Errors
PropertyDefinition : MethodDefinition
It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty.
negative:
phase: parse
type: SyntaxError
features: [class-methods-private, async-functions]
---*/
$DONOTEVALUATE();
var o = {
async #m() {}
};

View File

@ -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.
/*---
esid: sec-method-definitions-static-semantics-early-errors
description: >
Throws an early SyntaxError if a method definition has a private name even
inside a class body. (async generator)
info: |
Static Semantics: Early Errors
PropertyDefinition : MethodDefinition
It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty.
negative:
phase: parse
type: SyntaxError
features: [class-methods-private, async-iteration, class, class-fields-public]
---*/
$DONOTEVALUATE();
class C {
field = {
async * #m() {}
}
}

View File

@ -0,0 +1,24 @@
// Copyright (C) 2018 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-method-definitions-static-semantics-early-errors
description: >
Throws an early SyntaxError if a method definition has a private name.
(async generator)
info: |
Static Semantics: Early Errors
PropertyDefinition : MethodDefinition
It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty.
negative:
phase: parse
type: SyntaxError
features: [class-methods-private, async-iteration]
---*/
$DONOTEVALUATE();
var o = {
async * #m() {}
};

View File

@ -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.
/*---
esid: sec-method-definitions-static-semantics-early-errors
description: >
Throws an early SyntaxError if a method definition has a private name even
inside a class body. (generator)
info: |
Static Semantics: Early Errors
PropertyDefinition : MethodDefinition
It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty.
negative:
phase: parse
type: SyntaxError
features: [class-methods-private, generators, class, class-fields-public]
---*/
$DONOTEVALUATE();
class C {
field = {
* #m() {}
}
}

View File

@ -0,0 +1,24 @@
// Copyright (C) 2018 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-method-definitions-static-semantics-early-errors
description: >
Throws an early SyntaxError if a method definition has a private name.
(generator)
info: |
Static Semantics: Early Errors
PropertyDefinition : MethodDefinition
It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty.
negative:
phase: parse
type: SyntaxError
features: [class-methods-private, generators]
---*/
$DONOTEVALUATE();
var o = {
* #m() {}
};

View File

@ -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.
/*---
esid: sec-method-definitions-static-semantics-early-errors
description: >
Throws an early SyntaxError if a method definition has a private name even
inside a class body. (getter method)
info: |
Static Semantics: Early Errors
PropertyDefinition : MethodDefinition
It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty.
negative:
phase: parse
type: SyntaxError
features: [class-methods-private, class, class-fields-public]
---*/
$DONOTEVALUATE();
class C {
field = {
get #m() {}
}
}

View File

@ -0,0 +1,24 @@
// Copyright (C) 2018 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-method-definitions-static-semantics-early-errors
description: >
Throws an early SyntaxError if a method definition has a private name.
(getter method)
info: |
Static Semantics: Early Errors
PropertyDefinition : MethodDefinition
It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty.
negative:
phase: parse
type: SyntaxError
features: [class-methods-private]
---*/
$DONOTEVALUATE();
var o = {
get #m() {}
};

View File

@ -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.
/*---
esid: sec-method-definitions-static-semantics-early-errors
description: >
Throws an early SyntaxError if a method definition has a private name even
inside a class body. (ordinary method)
info: |
Static Semantics: Early Errors
PropertyDefinition : MethodDefinition
It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty.
negative:
phase: parse
type: SyntaxError
features: [class-methods-private, class, class-fields-public]
---*/
$DONOTEVALUATE();
class C {
field = {
#m() {}
}
}

View File

@ -0,0 +1,24 @@
// Copyright (C) 2018 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-method-definitions-static-semantics-early-errors
description: >
Throws an early SyntaxError if a method definition has a private name.
(ordinary method)
info: |
Static Semantics: Early Errors
PropertyDefinition : MethodDefinition
It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty.
negative:
phase: parse
type: SyntaxError
features: [class-methods-private]
---*/
$DONOTEVALUATE();
var o = {
#m() {}
};

View File

@ -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.
/*---
esid: sec-method-definitions-static-semantics-early-errors
description: >
Throws an early SyntaxError if a method definition has a private name even
inside a class body. (getter method)
info: |
Static Semantics: Early Errors
PropertyDefinition : MethodDefinition
It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty.
negative:
phase: parse
type: SyntaxError
features: [class-methods-private, class, class-fields-public]
---*/
$DONOTEVALUATE();
class C {
field = {
set #m(x) {}
}
}

View File

@ -0,0 +1,24 @@
// Copyright (C) 2018 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-method-definitions-static-semantics-early-errors
description: >
Throws an early SyntaxError if a method definition has a private name.
(getter method)
info: |
Static Semantics: Early Errors
PropertyDefinition : MethodDefinition
It is a Syntax Error if PrivateBoundNames of MethodDefinition is non-empty.
negative:
phase: parse
type: SyntaxError
features: [class-methods-private]
---*/
$DONOTEVALUATE();
var o = {
set #m(x) {}
};