fixed issue with nested properties

This commit is contained in:
Zdenko Vujasinovic
2017-08-21 16:22:17 +02:00
parent 2664c2c108
commit 232041db2a
2 changed files with 5 additions and 23 deletions

View File

@@ -2233,7 +2233,7 @@ exports.Assign = class Assign extends Base
nestedSource = new Value source.base, source.properties.concat [new Access getPropKey prop]
nestedSource = new Value new Op '?', nestedSource, nestedSourceDefault if nestedSourceDefault
else
nestedSource = source
nestedSource = new Value source, [new Access getPropKey prop]
restElements.push traverseRest(nestedProperties, nestedSource)...
else if prop instanceof Splat
prop.error "multiple rest elements are disallowed in object destructuring" if restIndex?
@@ -2251,15 +2251,7 @@ exports.Assign = class Assign extends Base
restElements
# Cache the value for reuse with rest elements.
# `Obj` should be always cached.
# Examples:
# {a, r...} = {a:1, b:2, c:3}
# {a, r...} = {a:1, obj...}
shouldCache = (value) ->
return yes if value.base instanceof Obj
value.shouldCache()
[@value, valueRef] = @value.cache o, false, shouldCache
[@value, valueRef] = @value.cache o
# Find all rest elements.
restElements = traverseRest @variable.base.properties, valueRef