This commit is contained in:
Zdenko Vujasinovic 2018-02-07 20:02:46 +01:00
parent eeeffef55d
commit d21cd72aa3
3 changed files with 27 additions and 2 deletions

View File

@ -4378,7 +4378,21 @@ this.toVar}`, upperBound = `${this.fromVar} >= ${idx} && ${gt} ${this.toVar}`, `
return this.name.assigns(name);
}
unrollSplat() {
if (!(this.name instanceof Obj)) {
return this.name;
}
}
// prop =
// if @name.properties?[0] instanceof Splat
// unrollSplat splat
// lg "2", splat
// return splat
compileNode(o) {
var lg;
lg = console.log;
console.log(this.isAssignable(), this.name.unwrapAll());
return [this.makeCode('...'), ...this.name.compileToFragments(o, LEVEL_OP)];
}

View File

@ -2923,7 +2923,18 @@ exports.Splat = class Splat extends Base
assigns: (name) ->
@name.assigns name
unrollSplat: ->
return @name unless @name instanceof Obj
# prop =
# if @name.properties?[0] instanceof Splat
# unrollSplat splat
# lg "2", splat
# return splat
compileNode: (o) ->
lg = console.log
console.log @isAssignable(), @name.unwrapAll()
[@makeCode('...'), @name.compileToFragments(o, LEVEL_OP)...]
unwrap: -> @name

View File

@ -925,8 +925,8 @@ test "#4673: complex destructured object spread variables", ->
{d.e...} = f: 1
eq d.e.f, 1
# {{g}...} = g: 1
# eq g, 1
{{g}...} = g: 1
eq g, 1
test "#4878: Compile error when using destructuring with a splat or expansion in an array", ->
arr = ['a', 'b', 'c', 'd']