Skip to content

parser: method definition with duplicate parameters in non-strict mode should throw a SyntaxError #10052

@Dunqing

Description

@Dunqing

Test262 test | Babel Playground | OXC Playground

// Copyright 2019 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
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
---*/

$DONOTEVALUATE();
({
  foo(a, a) { }
})

Expect

Both should throw a syntax error in non-strict mode and strict mode

Actual

Non-strict mode has no error, and strict mode has a syntax error

Metadata

Metadata

Assignees

Labels

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions