Skip to content

Commit d76043b

Browse files
committed
Anonymous kwargs
1 parent 8fbcd1b commit d76043b

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
66

77
## [Unreleased]
88

9+
### Changed
10+
11+
- Support forwarding anonymous keyword arguments with `**`.
12+
913
## [5.0.1] - 2022-11-10
1014

1115
### Changed

lib/syntax_tree/node.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,7 +1604,7 @@ def format_contents(q)
16041604
# { **pairs }
16051605
#
16061606
class AssocSplat < Node
1607-
# [untyped] the expression that is being splatted
1607+
# [nil | untyped] the expression that is being splatted
16081608
attr_reader :value
16091609

16101610
# [Array[ Comment | EmbDoc ]] the comments attached to this node
@@ -1643,7 +1643,7 @@ def deconstruct_keys(_keys)
16431643

16441644
def format(q)
16451645
q.text("**")
1646-
q.format(value)
1646+
q.format(value) if value
16471647
end
16481648

16491649
def ===(other)

lib/syntax_tree/parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ def on_assoc_splat(value)
744744

745745
AssocSplat.new(
746746
value: value,
747-
location: operator.location.to(value.location)
747+
location: operator.location.to((value || operator).location)
748748
)
749749
end
750750

test/fixtures/assoc_splat.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@
1212
}
1313
-
1414
{ **foo }
15+
% # >= 3.2.0
16+
def foo(**)
17+
bar(**)
18+
end

0 commit comments

Comments
 (0)