mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
#1643: Tag subpatterns in Assign#compilePatternMatch to prevent appending reference to RHS
This commit is contained in:
parent
6d0ba4b3bd
commit
03372c9b29
1 changed files with 3 additions and 2 deletions
|
@ -918,6 +918,7 @@ exports.Class = class Class extends Base
|
||||||
exports.Assign = class Assign extends Base
|
exports.Assign = class Assign extends Base
|
||||||
constructor: (@variable, @value, @context, options) ->
|
constructor: (@variable, @value, @context, options) ->
|
||||||
@param = options and options.param
|
@param = options and options.param
|
||||||
|
@subpattern = options and options.subpattern
|
||||||
|
|
||||||
children: ['variable', 'value']
|
children: ['variable', 'value']
|
||||||
|
|
||||||
|
@ -1032,8 +1033,8 @@ exports.Assign = class Assign extends Base
|
||||||
val = new Value new Literal(vvar), [new (if acc then Access else Index) idx]
|
val = new Value new Literal(vvar), [new (if acc then Access else Index) idx]
|
||||||
if name? and name in ['arguments','eval'].concat RESERVED
|
if name? and name in ['arguments','eval'].concat RESERVED
|
||||||
throw new SyntaxError "assignment to a reserved word: #{obj.compile o} = #{val.compile o}"
|
throw new SyntaxError "assignment to a reserved word: #{obj.compile o} = #{val.compile o}"
|
||||||
assigns.push new Assign(obj, val, null, param: @param).compile o, LEVEL_LIST
|
assigns.push new Assign(obj, val, null, param: @param, subpattern: yes).compile o, LEVEL_LIST
|
||||||
assigns.push vvar unless top
|
assigns.push vvar unless top or @subpattern
|
||||||
code = assigns.join ', '
|
code = assigns.join ', '
|
||||||
if o.level < LEVEL_LIST then code else "(#{code})"
|
if o.level < LEVEL_LIST then code else "(#{code})"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue