Closed kzc closed 6 years ago
Expected:
$ echo '((x) => {var obj = 2; console.log([{[x]: 1}, obj]);})(3);' | node
[ { '3': 1 }, 2 ]
Actual:
$ bin/buble -v
Bublé version 0.18.0
$ echo '((x) => {var obj = 2; console.log([{[x]: 1}, obj]);})(3);' | bin/buble | node
[ { '3': 1 }, { '3': 1 } ]
$ echo '((x) => {var obj = 2; console.log([{[x]: 1}, obj]);})(3);' | bin/buble
var obj;
(function (x) {var obj = 2; console.log([( obj = {}, obj[x] = 1, obj ), obj]);})(3);
This is a regression from buble@0.15.2
:
$ buble -v
Bublé version 0.15.2
$ echo '((x) => {var obj = 2; console.log([{[x]: 1}, obj]);})(3);' | buble
(function (x) {var obj = 2; console.log([( obj$1 = {}, obj$1[x] = 1, obj$1 ), obj]);
var obj$1;})(3);
$ echo '((x) => {var obj = 2; console.log([{[x]: 1}, obj]);})(3);' | buble | node
[ { '3': 1 }, 2 ]
Edited once bug was found. See bug in following comment.
This is just a case of suboptimal code generation.The temporary variable used by computed properties within an arrow function is not in the correct scope which can lead to slower code:compared to:
and