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

throws with object spread operator in assertion expression #6

Open
nfcampos opened this issue May 19, 2016 · 6 comments
Open

throws with object spread operator in assertion expression #6

nfcampos opened this issue May 19, 2016 · 6 comments

Comments

@nfcampos
Copy link

Description

const obj = {a: 1}
t.true(obj == {...obj})

throws the following exception

SyntaxError: Unexpected token (1:16)
    at Parser.pp.raise (/Users/nuno/cp/j2/node_modules/power-assert-formatter/node_modules/acorn/dist/acorn.js:943:13)
    at Parser.pp.unexpected (/Users/nuno/cp/j2/node_modules/power-assert-formatter/node_modules/acorn/dist/acorn.js:1503:8)
    at Parser.pp.parseIdent (/Users/nuno/cp/j2/node_modules/power-assert-formatter/node_modules/acorn/dist/acorn.js:670:10)
    at Parser.parseIdent (/Users/nuno/cp/j2/node_modules/acorn-es7-plugin/acorn-es7-plugin.js:93:19)
    at Parser.pp.parsePropertyName (/Users/nuno/cp/j2/node_modules/power-assert-formatter/node_modules/acorn/dist/acorn.js:554:127)
    at Parser.parsePropertyName (/Users/nuno/cp/j2/node_modules/acorn-es7-plugin/acorn-es7-plugin.js:219:19)
    at Parser.pp.parseObj (/Users/nuno/cp/j2/node_modules/power-assert-formatter/node_modules/acorn/dist/acorn.js:500:10)
    at Parser.pp.parseExprAtom (/Users/nuno/cp/j2/node_modules/power-assert-formatter/node_modules/acorn/dist/acorn.js:310:19)
    at Parser.parseExprAtom (/Users/nuno/cp/j2/node_modules/acorn-es7-plugin/acorn-es7-plugin.js:109:21)
    at Parser.pp.parseExprSubscripts (/Users/nuno/cp/j2/node_modules/power-assert-formatter/node_modules/acorn/dist/acorn.js:216:19)
    at Parser.pp.parseMaybeUnary (/Users/nuno/cp/j2/node_modules/power-assert-formatter/node_modules/acorn/dist/acorn.js:197:19)
    at Parser.pp.parseExprOp (/Users/nuno/cp/j2/node_modules/power-assert-formatter/node_modules/acorn/dist/acorn.js:173:42)
    at Parser.pp.parseExprOps (/Users/nuno/cp/j2/node_modules/power-assert-formatter/node_modules/acorn/dist/acorn.js:153:15)
    at Parser.pp.parseMaybeConditional (/Users/nuno/cp/j2/node_modules/power-assert-formatter/node_modules/acorn/dist/acorn.js:133:19)
    at Parser.pp.parseMaybeAssign (/Users/nuno/cp/j2/node_modules/power-assert-formatter/node_modules/acorn/dist/acorn.js:110:19)
    at Parser.pp.parseExprList (/Users/nuno/cp/j2/node_modules/power-assert-formatter/node_modules/acorn/dist/acorn.js:651:185)
@twada
Copy link
Owner

twada commented May 21, 2016

@nfcampos Thank you for reporting!
I assume that you are using AVA. I'm going to fix this.

@jamestalmage
Copy link
Contributor

Originally reported here: avajs/ava#797

Hey @twada! 😃

@dbettini
Copy link

Hey @twada , any update on this? I see you made a commit but it doesn't seem to work. babylon still throws Unexpected token error. I'm guessing it needs babel-plugin-transform-object-rest-spread plugin to work

@twada
Copy link
Owner

twada commented Oct 12, 2017

@dbettini Thanks and I forgot to close this issue since this is fixed a year ago.

On Babel6, you can use object spread operator by setting embedAst: true to babel-plugin-espower. Would you try it?
If it doesn't work. Would you give me a small reproduction case in a form of github repository or gist?

On Babel7, I need a tiny fix to run experimental features so please keep in touch. I'll release it in a few days.

@dbettini
Copy link

@twada since I'm using AVA, I just added babel-plugin-transform-object-rest-spread plugin by extending ava config in package.json

@twada
Copy link
Owner

twada commented Oct 18, 2017

@dbettini FYI avajs/ava#1554

twada added a commit that referenced this issue May 16, 2018
Allow a default message to be provided for a given pattern.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants