jquery / jquery/esprima

Parsing error when default export involves Array.concat

Open
#1,941 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
7.1k
Forks
773
PR merge metrics
No merged PRs in 30d

Description

Steps to reproduce
// okay
export default [...foo, ...bar]

// not okay
export default [].concat(foo)
                 ^

The bottom example is how the Buble compiler transforms something like [...foo].

Demo:
http://esprima.org/demo/parse.html?code=%2F%2F%20okay%0Aexport%20default%20%5B...foo%2C%20...bar%5D%0A%0A%2F%2F%20not%20okay%0Aexport%20default%20%5B%5D.concat(foo)

Expected output

Successful parse for the bottom example.

Actual output

Error: Line 5: Unexpected token .

Relevant references

Comparison with acorn on AST Explorer

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported examples in Esprima and compare the accepted array-spread export with the rejected [].concat(foo) default export. Trace the parser entry point for default-export expressions; done means the bottom example parses successfully without regressing the existing successful case.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.