Merge pull request #1915 from loganfsmyth/destructuring-default-hoisting

Ensure _blockHoist is set on function destructuring defaults
This commit is contained in:
Sebastian McKenzie 2015-07-05 19:24:01 +01:00
commit 4a84cd785a
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;
}