diff --git a/lib/coffee-script/nodes.js b/lib/coffee-script/nodes.js index f555bd76..7b7ff2cf 100644 --- a/lib/coffee-script/nodes.js +++ b/lib/coffee-script/nodes.js @@ -1153,6 +1153,9 @@ } } if (!splat && obj instanceof Splat) { + if (!obj.name.unwrapAll().isAssignable()) { + throw SyntaxError("\"" + (obj.name.compile(o)) + "\" cannot be assigned."); + } name = obj.name.unwrap().value; val = "" + olen + " <= " + vvar + ".length ? " + (utility('slice')) + ".call(" + vvar + ", " + i; if (rest = olen - i - 1) { diff --git a/src/nodes.coffee b/src/nodes.coffee index 954ec9d1..4f3f2634 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -1005,6 +1005,8 @@ exports.Assign = class Assign extends Base else idx = if obj.this then obj.properties[0].name else obj if not splat and obj instanceof Splat + unless obj.name.unwrapAll().isAssignable() + throw SyntaxError "\"#{ obj.name.compile(o) }\" cannot be assigned." name = obj.name.unwrap().value val = "#{olen} <= #{vvar}.length ? #{ utility 'slice' }.call(#{vvar}, #{i}" if rest = olen - i - 1