@@ -830,7 +830,7 @@ def on_args_add_block(arguments, block)
830
830
# method(*arguments)
831
831
#
832
832
class ArgStar
833
- # [untyped] the expression being splatted
833
+ # [nil | untyped] the expression being splatted
834
834
attr_reader :value
835
835
836
836
# [Location] the location of this node
@@ -3855,7 +3855,7 @@ def on_fndptn(constant, left, values, right)
3855
3855
# end
3856
3856
#
3857
3857
class For
3858
- # [MLHS | MLHSAddStar | VarField] the variable declaration being used to
3858
+ # [MLHS | VarField] the variable declaration being used to
3859
3859
# pull values out of the object being enumerated
3860
3860
attr_reader :index
3861
3861
@@ -3903,7 +3903,7 @@ def to_json(*opts)
3903
3903
3904
3904
# :call-seq:
3905
3905
# on_for: (
3906
- # (MLHS | MLHSAddStar | VarField) value,
3906
+ # (MLHS | VarField) value,
3907
3907
# untyped collection,
3908
3908
# Statements statements
3909
3909
# ) -> For
@@ -5238,8 +5238,8 @@ def on_method_add_block(call, block)
5238
5238
# first, second, third = value
5239
5239
#
5240
5240
class MLHS
5241
- # Array[ARefField | Field | Ident | MlhsParen | VarField] the parts of
5242
- # the left-hand side of a multiple assignment
5241
+ # Array[ARefField | ArgStar | Field | Ident | MlhsParen | VarField] the
5242
+ # parts of the left-hand side of a multiple assignment
5243
5243
attr_reader :parts
5244
5244
5245
5245
# [boolean] whether or not there is a trailing comma at the end of this
@@ -5276,14 +5276,14 @@ def to_json(*opts)
5276
5276
# (ARefField | Field | Ident | MlhsParen | VarField) part
5277
5277
# ) -> MLHS
5278
5278
def on_mlhs_add ( mlhs , part )
5279
- if mlhs . parts . empty?
5280
- MLHS . new ( parts : [ part ] , location : part . location )
5281
- else
5282
- MLHS . new (
5283
- parts : mlhs . parts << part ,
5284
- location : mlhs . location . to ( part . location )
5285
- )
5286
- end
5279
+ location =
5280
+ if mlhs . parts . empty?
5281
+ part . location
5282
+ else
5283
+ mlhs . location . to ( part . location )
5284
+ end
5285
+
5286
+ MLHS . new ( parts : mlhs . parts << part , location : location )
5287
5287
end
5288
5288
5289
5289
# MLHSAddPost represents adding another set of variables onto a list of
@@ -5327,7 +5327,7 @@ def to_json(*opts)
5327
5327
end
5328
5328
5329
5329
# :call-seq:
5330
- # on_mlhs_add_post: (MLHSAddStar star, MLHS mlhs) -> MLHSAddPost
5330
+ # on_mlhs_add_post: (MLHS star, MLHS mlhs) -> MLHSAddPost
5331
5331
def on_mlhs_add_post ( star , mlhs )
5332
5332
MLHSAddPost . new (
5333
5333
star : star ,
@@ -5336,61 +5336,20 @@ def on_mlhs_add_post(star, mlhs)
5336
5336
)
5337
5337
end
5338
5338
5339
- # MLHSAddStar represents a splatted variable inside of a multiple assignment
5340
- # on the left hand side.
5341
- #
5342
- # first, *rest = values
5343
- #
5344
- class MLHSAddStar
5345
- # [MLHS] the values before the starred expression
5346
- attr_reader :mlhs
5347
-
5348
- # [nil | ARefField | Field | Ident | VarField] the expression being
5349
- # splatted
5350
- attr_reader :star
5351
-
5352
- # [Location] the location of this node
5353
- attr_reader :location
5354
-
5355
- def initialize ( mlhs :, star :, location :)
5356
- @mlhs = mlhs
5357
- @star = star
5358
- @location = location
5359
- end
5360
-
5361
- def pretty_print ( q )
5362
- q . group ( 2 , '(' , ')' ) do
5363
- q . text ( 'mlhs_add_star' )
5364
-
5365
- q . breakable
5366
- q . pp ( mlhs )
5367
-
5368
- q . breakable
5369
- q . pp ( star )
5370
- end
5371
- end
5372
-
5373
- def to_json ( *opts )
5374
- { type : :mlhs_add_star , mlhs : mlhs , star : star , loc : location } . to_json (
5375
- *opts
5376
- )
5377
- end
5378
- end
5379
-
5380
5339
# :call-seq:
5381
5340
# on_mlhs_add_star: (
5382
5341
# MLHS mlhs,
5383
5342
# (nil | ARefField | Field | Ident | VarField) part
5384
- # ) -> MLHSAddStar
5343
+ # ) -> MLHS
5385
5344
def on_mlhs_add_star ( mlhs , part )
5386
5345
beginning = find_token ( Op , '*' )
5387
5346
ending = part || beginning
5388
5347
5389
- MLHSAddStar . new (
5390
- mlhs : mlhs ,
5391
- star : part ,
5392
- location : beginning . location . to ( ending . location )
5393
- )
5348
+ location = beginning . location . to ( ending . location )
5349
+ arg_star = ArgStar . new ( value : part , location : location )
5350
+
5351
+ location = mlhs . location . to ( location ) unless mlhs . parts . empty?
5352
+ MLHS . new ( parts : mlhs . parts << arg_star , location : location )
5394
5353
end
5395
5354
5396
5355
# :call-seq:
0 commit comments