jquery / jquery/esprima

Missing Spreadoperator compliance in dict

Open
#2,129 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Running a dict containing a Spreadoperator gives an error:

babel/parser.parse() on this :
const a = {'a':'b','b':'b','c':'c'};
const b = {'z':'z'};
const y = {...a,...b};

gives Following error:

Error: Line 3: Unexpected token ...
at ErrorHandler.constructError (/Users/anton/Documents/firebase/NodeJs/node_modules/.pnpm/esprima@4.0.1/node_modules/esprima/dist/esprima.js:5012:22)
at ErrorHandler.createError (/Users/anton/Documents/firebase/NodeJs/node_modules/.pnpm/esprima@4.0.1/node_modules/esprima/dist/esprima.js:5028:27)
at Parser.unexpectedTokenError (/Users/anton/Documents/firebase/NodeJs/node_modules/.pnpm/esprima@4.0.1/node_modules/esprima/dist/esprima.js:1985:39)
at Parser.throwUnexpectedToken (/Users/anton/Documents/firebase/NodeJs/node_modules/.pnpm/esprima@4.0.1/node_modules/esprima/dist/esprima.js:1995:21)
at Parser.parseObjectPropertyKey (/Users/anton/Documents/firebase/NodeJs/node_modules/.pnpm/esprima@4.0.1/node_modules/esprima/dist/esprima.js:2499:33)
at Parser.parseObjectProperty (/Users/anton/Documents/firebase/NodeJs/node_modules/.pnpm/esprima@4.0.1/node_modules/esprima/dist/esprima.js:2534:25)
at Parser.parseObjectInitializer (/Users/anton/Documents/firebase/NodeJs/node_modules/.pnpm/esprima@4.0.1/node_modules/esprima/dist/esprima.js:2602:35)
at Parser.inheritCoverGrammar (/Users/anton/Documents/firebase/NodeJs/node_modules/.pnpm/esprima@4.0.1/node_modules/esprima/dist/esprima.js:2285:37)
at Parser.parsePrimaryExpression (/Users/anton/Documents/firebase/NodeJs/node_modules/.pnpm/esprima@4.0.1/node_modules/esprima/dist/esprima.js:2354:38)
at Parser.inheritCoverGrammar (/Users/anton/Documents/firebase/NodeJs/node_modules/.pnpm/esprima@4.0.1/node_modules/esprima/dist/esprima.js:2285:37) {
index: 69,
lineNumber: 3,
description: 'Unexpected token ...'
}

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

Start by reproducing the reported object spread example with the parser entry point used in this repository. Trace how object initializers handle the ... token, then add coverage showing that {...a,...b} parses successfully without the reported unexpected-token error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.