Ensure _blockHoist is set on function destructuring defaults - fixes #1908

This commit is contained in:
Logan Smyth 2015-07-03 11:23:02 -07:00
parent 64903d0dcf
commit f47d17345c
3 changed files with 9 additions and 4 deletions

View File

@ -316,9 +316,12 @@ class DestructuringTransformer {
var left = pattern.left;
if (t.isPattern(left)) {
this.nodes.push(t.expressionStatement(
var tempValueDefault = t.expressionStatement(
t.assignmentExpression("=", tempValueRef, tempConditional)
));
);
tempValueDefault._blockHoist = this.blockHoist;
this.nodes.push(tempValueDefault);
this.push(left, tempValueRef);
} else {
this.nodes.push(this.buildVariableAssignment(left, tempConditional));

View File

@ -1,4 +1,4 @@
function somethingAdvanced({topLeft: {x: x1, y: y1}, bottomRight: {x: x2, y: y2}}){
function somethingAdvanced({topLeft: {x: x1, y: y1} = {}, bottomRight: {x: x2, y: y2} = {}}, p2, p3){
}

View File

@ -1,10 +1,12 @@
"use strict";
function somethingAdvanced(_ref) {
function somethingAdvanced(_ref, p2, p3) {
var _ref$topLeft = _ref.topLeft;
_ref$topLeft = _ref$topLeft === undefined ? {} : _ref$topLeft;
var x1 = _ref$topLeft.x;
var y1 = _ref$topLeft.y;
var _ref$bottomRight = _ref.bottomRight;
_ref$bottomRight = _ref$bottomRight === undefined ? {} : _ref$bottomRight;
var x2 = _ref$bottomRight.x;
var y2 = _ref$bottomRight.y;
}