v8/v8.dev

Nodejs (V8 engine) compiler bug report

siroossheikhi opened this issue · 1 comments

Hi Guys
Today while I was coding realized destructuring assignment will not work correctly when write immediately after close brace of object defining without semicolon.
You can re-create bug using below sample codes. my node version is 12.16.2

Close brace of object defining without semicolon

let a,b,c
a={x:1} //<~~~without semicolon
[b, c] = [1, 2]
console.log(b)
console.log(c)

above code will return

undefined
undefined

Close brace of object defining with semicolon

let a,b,c
a={x:1}; //<~~~with semicolon
[b, c] = [1, 2]
console.log(b)
console.log(c)

above code will return

1
2

Close brace of if statement

let a,b,c
if(1===1){
a = 1
} //<~~~without semicolon
[b, c] = [1, 2]
console.log(b)
console.log(c)

above code will return

1
2

Next time please report (suspected) bugs at crbug.com/v8/new.

This is working as intended; see the ASI spec at https://tc39.es/ecma262/#sec-automatic-semicolon-insertion.