mirror of https://github.com/tc39/test262.git
Improve coverage for UniqueFormalParameters (#2043)
Previously, the early error prohibiting duplicate entries in UniqueFormalParameters was only tested in terms of async functions. In one case, this was misattributed to UniqeFormalParameters and only enforced for strict mode code. Extend coverage to the other function-creating productions which include UniqueFormalParameters (i.e. method definitions and non-async arrow functions), and update the existing tests to more accurately describe the source of the error.
This commit is contained in:
parent
d7c8a12e68
commit
9fccd9852e
|
@ -0,0 +1,33 @@
|
|||
// Copyright 2019 Mike Pennisi. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-arrow-function-definitions
|
||||
description: Formal parameters may not contain duplicates
|
||||
info: |
|
||||
# 14.2 Arrow Function Definitions
|
||||
|
||||
When the production
|
||||
|
||||
ArrowParameters:CoverParenthesizedExpressionAndArrowParameterList
|
||||
|
||||
is recognized the following grammar is used to refine the interpretation
|
||||
of CoverParenthesizedExpressionAndArrowParameterList:
|
||||
|
||||
ArrowFormalParameters[Yield, Await]:
|
||||
(UniqueFormalParameters[?Yield, ?Await])
|
||||
|
||||
# 14.1.2 Static Semantics: Early Errors
|
||||
|
||||
UniqueFormalParameters:FormalParameters
|
||||
|
||||
- It is a Syntax Error if BoundNames of FormalParameters contains any
|
||||
duplicate elements.
|
||||
negative:
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
---*/
|
||||
|
||||
$DONOTEVALUATE();
|
||||
|
||||
0, (a, a) => { };
|
|
@ -3,13 +3,30 @@
|
|||
|
||||
/*---
|
||||
author: Brian Terlson <brian.terlson@microsoft.com>
|
||||
esid: pending
|
||||
description: >
|
||||
If strict mode, early error rules for StrictFormalParameters are applied
|
||||
esid: sec-async-arrow-function-definitions
|
||||
description: Formal parameters may not contain duplicates
|
||||
info: |
|
||||
# 14.2 Arrow Function Definitions
|
||||
|
||||
When the production
|
||||
|
||||
ArrowParameters:CoverParenthesizedExpressionAndArrowParameterList
|
||||
|
||||
is recognized the following grammar is used to refine the interpretation
|
||||
of CoverParenthesizedExpressionAndArrowParameterList:
|
||||
|
||||
ArrowFormalParameters[Yield, Await]:
|
||||
(UniqueFormalParameters[?Yield, ?Await])
|
||||
|
||||
# 14.1.2 Static Semantics: Early Errors
|
||||
|
||||
UniqueFormalParameters:FormalParameters
|
||||
|
||||
- It is a Syntax Error if BoundNames of FormalParameters contains any
|
||||
duplicate elements.
|
||||
negative:
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
flags: [onlyStrict]
|
||||
---*/
|
||||
|
||||
$DONOTEVALUATE();
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2016 Microsoft, Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Brian Terlson <brian.terlson@microsoft.com>
|
||||
esid: sec-async-function-definitions
|
||||
description: Formal parameters may not contain duplicates
|
||||
info: |
|
||||
# 14.7 Async Function Definitions
|
||||
|
||||
AsyncMethod[Yield, Await]:
|
||||
async[no LineTerminator here]PropertyName[?Yield, ?Await](UniqueFormalParameters[~Yield, +Await]){AsyncFunctionBody}
|
||||
|
||||
# 14.1.2 Static Semantics: Early Errors
|
||||
|
||||
UniqueFormalParameters:FormalParameters
|
||||
|
||||
- It is a Syntax Error if BoundNames of FormalParameters contains any
|
||||
duplicate elements.
|
||||
negative:
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
---*/
|
||||
|
||||
$DONOTEVALUATE();
|
||||
({
|
||||
async foo(a, a) { }
|
||||
})
|
|
@ -1,11 +1,21 @@
|
|||
// Copyright 2016 Microsoft, Inc. All rights reserved.
|
||||
// Copyright 2019 Mike Pennisi. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Brian Terlson <brian.terlson@microsoft.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Early error rules for StrictFormalParameters are applied
|
||||
esid: sec-method-definitions
|
||||
description: Formal parameters may not contain duplicates
|
||||
info: |
|
||||
# 14.3 Method Definitions
|
||||
|
||||
MethodDefinition[Yield, Await]:
|
||||
PropertyName[?Yield, ?Await](UniqueFormalParameters[~Yield, ~Await]){FunctionBody[~Yield, ~Await]}
|
||||
|
||||
# 14.1.2 Static Semantics: Early Errors
|
||||
|
||||
UniqueFormalParameters:FormalParameters
|
||||
|
||||
- It is a Syntax Error if BoundNames of FormalParameters contains any
|
||||
duplicate elements.
|
||||
negative:
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
|
@ -13,5 +23,5 @@ negative:
|
|||
|
||||
$DONOTEVALUATE();
|
||||
({
|
||||
async foo(a, a) { }
|
||||
foo(a, a) { }
|
||||
})
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright 2016 Microsoft, Inc. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Brian Terlson <brian.terlson@microsoft.com>
|
||||
esid: sec-async-function-definitions
|
||||
description: Formal parameters may not contain duplicates
|
||||
info: |
|
||||
# 14.7 Arrow Function Definitions
|
||||
|
||||
AsyncMethod[Yield, Await]:
|
||||
async[no LineTerminator here]PropertyName[?Yield, ?Await](UniqueFormalParameters[~Yield, +Await]){AsyncFunctionBody}
|
||||
|
||||
# 14.1.2 Static Semantics: Early Errors
|
||||
|
||||
UniqueFormalParameters:FormalParameters
|
||||
|
||||
- It is a Syntax Error if BoundNames of FormalParameters contains any
|
||||
duplicate elements.
|
||||
negative:
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
---*/
|
||||
|
||||
$DONOTEVALUATE();
|
||||
|
||||
class Foo {
|
||||
async foo(a, a) { }
|
||||
}
|
|
@ -1,11 +1,21 @@
|
|||
// Copyright 2016 Microsoft, Inc. All rights reserved.
|
||||
// Copyright 2019 Mike Pennisi. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
author: Brian Terlson <brian.terlson@microsoft.com>
|
||||
esid: pending
|
||||
description: >
|
||||
Early error rules for StrictFormalParameters are applied
|
||||
esid: sec-method-definitions
|
||||
description: Formal parameters may not contain duplicates
|
||||
info: |
|
||||
# 14.3 Method Definitions
|
||||
|
||||
MethodDefinition[Yield, Await]:
|
||||
PropertyName[?Yield, ?Await](UniqueFormalParameters[~Yield, ~Await]){FunctionBody[~Yield, ~Await]}
|
||||
|
||||
# 14.1.2 Static Semantics: Early Errors
|
||||
|
||||
UniqueFormalParameters:FormalParameters
|
||||
|
||||
- It is a Syntax Error if BoundNames of FormalParameters contains any
|
||||
duplicate elements.
|
||||
negative:
|
||||
phase: parse
|
||||
type: SyntaxError
|
||||
|
@ -14,5 +24,5 @@ negative:
|
|||
$DONOTEVALUATE();
|
||||
|
||||
class Foo {
|
||||
async foo(a, a) { }
|
||||
foo(a, a) { }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue