Skip to content

Commit 5a709ed

Browse files
author
Zdenko Vujasinovic
committed
improve variable declaration
1 parent 2491d32 commit 5a709ed

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

lib/coffeescript/nodes.js

Lines changed: 10 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/nodes.coffee

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,12 +2255,16 @@ exports.Assign = class Assign extends Base
22552255
restElements
22562256

22572257
# Cache the value for reuse with rest elements.
2258-
[@value, valueRef] = @value.cache o
2258+
if @value.shouldCache()
2259+
valueRefTemp = new IdentifierLiteral o.scope.freeVariable 'ref', reserve: false
2260+
else
2261+
valueRefTemp = @value.base
22592262

22602263
# Find all rest elements.
2261-
restElements = traverseRest @variable.base.properties, valueRef
2262-
return false unless restElements and restElements.length > 0
2264+
restElements = traverseRest @variable.base.properties, valueRefTemp
2265+
return no unless restElements and restElements.length > 0
22632266

2267+
[@value, valueRef] = @value.cache o
22642268
result = new Block [@]
22652269

22662270
for restElement in restElements

0 commit comments

Comments
 (0)