throw an error when destructuring a null or undefined value on an empty object pattern - fixes #681

This commit is contained in:
Sebastian McKenzie
2015-02-04 17:35:24 +11:00
parent 4f023e83f8
commit 58bed088f5
6 changed files with 22 additions and 1 deletions

View File

@@ -0,0 +1 @@
var {} = null;

View File

@@ -0,0 +1,3 @@
assert.throws(function () {
var {} = null;
}, /Cannot destructure undefined/);

View File

@@ -0,0 +1,7 @@
"use strict";
var _objectDestructuringEmpty = function (obj) { if (obj == null) throw new TypeError("Cannot destructure undefined"); };
var _ref = null;
_objectDestructuringEmpty(_ref);