Bug: ObjectPat Syntax Error for { a } = { a: 1 }
caoccao opened this issue · comments
Sam Cao commented
Describe the bug
Problem
{ a } = { a: 1 }
works in Node.js well, but fails to be parsed by SWC.
Result in Node.js
Welcome to Node.js v20.8.0.
Type ".help" for more information.
> let a
undefined
> { a } = { a: 1 }
{ a: 1 }
> a
1
>
Result in SWC
x Expression expected
,----
1 | { a } = { a: 1 }
: ^
`----
Caused by:
0: failed to parse code
1: Syntax Error
Input code
{ a } = { a: 1 }
Config
{
"jsc": {
"parser": {
"syntax": "ecmascript",
"jsx": false
},
"target": "es2020",
"loose": false,
"minify": {
"compress": false,
"mangle": false
}
},
"module": {
"type": "es6"
},
"minify": false,
"isModule": false
}
Playground link (or link to the minimal reproduction)
SWC Info output
1.5.5
Expected behavior
{ a } = { a: 1 }
should pass the syntax check.
Actual behavior
No response
Version
1.5.5
Additional context
No response
Donny/강동윤 commented
Sam Cao commented
Thank you for the quick response. You are right.
I just tried in d8 and got an syntax error.
V8 version 12.5.227.6
d8> let a
undefined
d8> { a } = { a: 1 }
(d8):1: SyntaxError: Unexpected token '='
{ a } = { a: 1 }
^
SyntaxError: Unexpected token '='