Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should not allow duplicate exported names #2054

Open
ljqx opened this issue Dec 7, 2020 · 0 comments
Open

Should not allow duplicate exported names #2054

ljqx opened this issue Dec 7, 2020 · 0 comments

Comments

@ljqx
Copy link
Contributor

ljqx commented Dec 7, 2020

Steps to reproduce

esprima.parse(`
export let a = '1';
export let a = '2';
`)

Expected output

Syntax error.

Actual output

{
  "type": "Program",
  "body": [
    {
      "type": "ExportNamedDeclaration",
      "declaration": {
        "type": "VariableDeclaration",
        "declarations": [
          {
            "type": "VariableDeclarator",
            "id": {
              "type": "Identifier",
              "name": "a"
            },
            "init": {
              "type": "Literal",
              "value": "1",
              "raw": "'1'"
            }
          }
        ],
        "kind": "let"
      },
      "specifiers": [],
      "source": null
    },
    {
      "type": "ExportNamedDeclaration",
      "declaration": {
        "type": "VariableDeclaration",
        "declarations": [
          {
            "type": "VariableDeclarator",
            "id": {
              "type": "Identifier",
              "name": "a"
            },
            "init": {
              "type": "Literal",
              "value": "2",
              "raw": "'2'"
            }
          }
        ],
        "kind": "let"
      },
      "specifiers": [],
      "source": null
    }
  ],
  "sourceType": "module"
}

Relevant references

The spec: https://tc39.es/ecma262/#sec-module-semantics-static-semantics-early-errors

It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant