Skip to content

Commit fa8f8c3

Browse files
committed
Fixed changes to AST for splat
[git-p4: depot-paths = "//src/ruby_parser/dev/": change = 4442]
1 parent 2c3ed40 commit fa8f8c3

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/ruby_parser.y

+1-1
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ rule
716716
}
717717
| tSTAR arg opt_nl
718718
{
719-
result = s(:splat, val[1])
719+
result = s(:array, s(:splat, val[1]))
720720
result.paren = true
721721
}
722722

lib/ruby_parser_extras.rb

+11-1
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,10 @@ def new_super args
647647
s(:super, args)
648648
else
649649
args ||= s(:arglist)
650+
if args[0] == :arglist && args.splat then
651+
args[0] = :array
652+
args = s(:dummy, args)
653+
end
650654
s(:super, *args[1..-1])
651655
end
652656
end
@@ -696,11 +700,16 @@ def new_xstring str
696700
end
697701

698702
def new_yield args = nil
703+
# TODO: raise args.inspect unless [:arglist].include? args.first # HACK
699704
raise SyntaxError, "Block argument should not be given." if
700705
args && args.node_type == :block_pass
701706

702707
args ||= s(:arglist)
703-
args = s(:arglist, args) unless [:arglist, :array].include? args.first
708+
709+
# TODO: I can prolly clean this up
710+
args[0] = :arglist if args.first == :array
711+
args[0] = :array if args[0] == :arglist && args.splat
712+
args = s(:arglist, args) unless args.first == :arglist
704713

705714
return s(:yield, *args[1..-1])
706715
end
@@ -773,6 +782,7 @@ def ret_args node
773782
# HACK matz wraps ONE of the FOUR splats in a newline to
774783
# distinguish. I use paren for now. ugh
775784
node = s(:svalue, node) if node[0] == :splat and not node.paren
785+
node[0] = :svalue if node[0] == :arglist && node[1][0] == :splat
776786
end
777787

778788
node

0 commit comments

Comments
 (0)