Skip to content

Missing Spreadoperator compliance in dict  #2129

Open

Description

@Anton3210

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 ...'
}

Activity

  1. mmiscool commented on Dec 3, 2024

    @mmiscool

    I am getting the same error.
    Is this library still being maintained at all?

  2. Meir017 commented on Dec 3, 2024

    @Meir017
    Contributor
  3. Anton3210 commented on Dec 4, 2024

    @Anton3210
    Author

    I´m using acorn now

    import * as acorn_walk from 'acorn-walk';
    import { ancestor } from 'acorn-walk';
    function findNodeByValue(ast, value) {
    let path = [];
    let callback = function(){}
    let functionBase = {...acorn_walk.base};
    functionBase.Literal = function(node,_state,ancestor){
    count++;
    if (node.value==value) {
    path.push({"node":node,"ancestor":ancestor})
    }
    }
    acorn_walk.fullAncestor(ast,function(a,b,c){},functionBase
    );//node, callback, baseVisitor, state, override

    return path;
    

    }
    ast = acorn.parse(strings,{
    // parse in strict mode and allow module declarations
    sourceType: "script",
    ecmaVersion : 12,

    plugins: [
    // enable jsx and flow syntax
    "jsx",
    "flow",
    ],
    })

  4. mmiscool commented on Dec 5, 2024

    @mmiscool

    @mmiscool try here https://github.com/node-projects/esprima-next

    This package worked perfectly for me. Thanks for pointing it out.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions