diff --git a/lib/6to5/transformation/transformers/es6/destructuring.js b/lib/6to5/transformation/transformers/es6/destructuring.js index bf94da2cca..246edf31ee 100644 --- a/lib/6to5/transformation/transformers/es6/destructuring.js +++ b/lib/6to5/transformation/transformers/es6/destructuring.js @@ -46,9 +46,11 @@ var push = function (opts, nodes, elem, parentId) { var pushAssignmentPattern = function (opts, nodes, pattern, parentId) { var tempParentId = opts.scope.generateUidBasedOnNode(parentId, opts.file); - nodes.push(t.variableDeclaration("var", [ + var declar = t.variableDeclaration("var", [ t.variableDeclarator(tempParentId, parentId) - ])); + ]); + declar._blockHoist = opts.blockHoist; + nodes.push(declar); nodes.push(buildVariableAssign( opts, diff --git a/test/fixtures/transformation/regenerator/destructuring/exec.js b/test/fixtures/transformation/regenerator/destructuring/exec.js index b9cf63e289..483a5724c1 100644 --- a/test/fixtures/transformation/regenerator/destructuring/exec.js +++ b/test/fixtures/transformation/regenerator/destructuring/exec.js @@ -3,4 +3,11 @@ function* foo() { return bar; } -assert.deepEqual(foo().next().value, "bar"); +assert.equal(foo().next().value, "bar"); + +function *foo({ bar = 0 }) { + return bar; +} + +assert.equal(foo({ bar: undefined }).next(), 0); +assert.equal(foo({ bar: 3 }).next(), 3);