1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

fixes #1591: splatted expressions in destructuring assignment must be assignable

This commit is contained in:
Gerald Lewis 2011-08-30 11:12:25 -04:00
parent c0e0ede09f
commit e17b67e6f2
2 changed files with 5 additions and 0 deletions

View file

@ -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) {

View file

@ -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