diff --git a/src/babel/types/validators.js b/src/babel/types/validators.js index cbf82b33ee..f5985625e4 100644 --- a/src/babel/types/validators.js +++ b/src/babel/types/validators.js @@ -26,10 +26,11 @@ export function isReferenced(node: Object, parent: Object): boolean { return false; // yes: { [NODE]: "" } + // yes: { NODE } // no: { NODE: "" } case "Property": if (parent.key === node) { - return parent.computed; + return parent.computed || parent.shorthand; } // no: var NODE = init; diff --git a/test/core/fixtures/transformation/spec.function-name/assignment/expected.js b/test/core/fixtures/transformation/spec.function-name/assignment/expected.js index 817b70b57f..165873a40c 100644 --- a/test/core/fixtures/transformation/spec.function-name/assignment/expected.js +++ b/test/core/fixtures/transformation/spec.function-name/assignment/expected.js @@ -4,9 +4,19 @@ var _i = function i() { _i = 5; }; -var j = function j() { +var j = (function (_j) { + function j() { + return _j.apply(this, arguments); + } + + j.toString = function () { + return _j.toString(); + }; + + return j; +})(function () { var _ = 5; j = _.j; ; -}; +}); diff --git a/test/core/fixtures/transformation/validation.undeclared-variable-check/undeclared-shorthand-property/exec.js b/test/core/fixtures/transformation/validation.undeclared-variable-check/undeclared-shorthand-property/exec.js new file mode 100644 index 0000000000..ee11821ed0 --- /dev/null +++ b/test/core/fixtures/transformation/validation.undeclared-variable-check/undeclared-shorthand-property/exec.js @@ -0,0 +1 @@ +({foo}) diff --git a/test/core/fixtures/transformation/validation.undeclared-variable-check/undeclared-shorthand-property/options.json b/test/core/fixtures/transformation/validation.undeclared-variable-check/undeclared-shorthand-property/options.json new file mode 100644 index 0000000000..a661ffc703 --- /dev/null +++ b/test/core/fixtures/transformation/validation.undeclared-variable-check/undeclared-shorthand-property/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Reference to undeclared variable" +}