Skip to content
Snippets Groups Projects
Commit 9fccd985 authored by jugglinmike's avatar jugglinmike Committed by Leo Balter
Browse files

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.
parent d7c8a12e
No related branches found
No related tags found
No related merge requests found
// 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();
......
// 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) { }
})
// 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) { }
})
// 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) { }
}
// 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) { }
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment