-
Notifications
You must be signed in to change notification settings - Fork 20
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
Parse error with arrow function returning object literal #38
Comments
Some additional context: Source which fails: $source = 'const foo = () => ({ ...(void 0) });';
$ast = Peast\Peast::latest( $source )->parse();
AST based on https://astexplorer.net/{
"type": "Program",
"start": 0,
"end": 36,
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 36,
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 35,
"id": {
"type": "Identifier",
"start": 6,
"end": 9,
"name": "foo"
},
"init": {
"type": "ArrowFunctionExpression",
"start": 12,
"end": 35,
"id": null,
"expression": true,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "ObjectExpression",
"start": 19,
"end": 34,
"properties": [
{
"type": "SpreadElement",
"start": 21,
"end": 32,
"argument": {
"type": "UnaryExpression",
"start": 25,
"end": 31,
"operator": "void",
"prefix": true,
"argument": {
"type": "Literal",
"start": 30,
"end": 31,
"value": 0,
"raw": "0"
}
}
}
]
}
}
}
],
"kind": "const"
}
],
"sourceType": "module"
} Source which passes: $source = 'const foo = () => {
return { ...(void 0) };
};';
$ast = Peast\Peast::latest( $source )->parse(); Value of $ast
|
I've just fixed this error, the problem wasn't the object itself but the spread operator inside it, the parser was failing too early when consuming it. Thank you for reporting! |
Hi @mck89 thanks for the quick fix. Confirming that it's now working as expected. Are you planning to publish the fix in a patch release? |
I've released version 1.13.2 with this bugfix |
Peast currently fails to parse this code:
I'm getting:
Whereas this works:
This fails as well
This passes:
The text was updated successfully, but these errors were encountered: