diff options
author | Kevin Newton <kddnewton@gmail.com> | 2023-11-28 15:49:04 -0500 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-11-28 22:33:50 +0000 |
commit | 49383901772f874569bbdc992867bd02b4b597a8 (patch) | |
tree | abd79930a7511b6504a6314f4aab6a0869d86e66 /test/prism/snapshots | |
parent | ea3e17e430b74b4e58535a707319025e008cc123 (diff) | |
download | ruby-49383901772f874569bbdc992867bd02b4b597a8.tar.gz |
[ruby/prism] Implicit rest nodes
Fundamentally, `foo { |bar,| }` is different from `foo { |bar, *| }`
because of arity checks. This PR introduces a new node to handle
that, `ImplicitRestNode`, which goes in the `rest` slot of parameter
nodes instead of `RestParameterNode` instances.
This is also used in a couple of other places, namely:
* pattern matching: `foo in [bar,]`
* multi target: `for foo, in bar do end`
* multi write: `foo, = bar`
Now the only splat nodes with a `NULL` value are when you're
forwarding, as in: `def foo(*) = bar(*)`.
https://github.com/ruby/prism/commit/dba2a3b652
Diffstat (limited to 'test/prism/snapshots')
-rw-r--r-- | test/prism/snapshots/blocks.txt | 5 | ||||
-rw-r--r-- | test/prism/snapshots/seattlerb/bug236.txt | 5 | ||||
-rw-r--r-- | test/prism/snapshots/seattlerb/masgn_command_call.txt | 4 | ||||
-rw-r--r-- | test/prism/snapshots/seattlerb/parse_pattern_051.txt | 3 | ||||
-rw-r--r-- | test/prism/snapshots/unparser/corpus/literal/assignment.txt | 8 | ||||
-rw-r--r-- | test/prism/snapshots/unparser/corpus/literal/block.txt | 10 | ||||
-rw-r--r-- | test/prism/snapshots/unparser/corpus/literal/pattern.txt | 3 | ||||
-rw-r--r-- | test/prism/snapshots/variables.txt | 4 | ||||
-rw-r--r-- | test/prism/snapshots/whitequark/blockargs.txt | 10 | ||||
-rw-r--r-- | test/prism/snapshots/whitequark/masgn_nested.txt | 4 |
10 files changed, 15 insertions, 41 deletions
diff --git a/test/prism/snapshots/blocks.txt b/test/prism/snapshots/blocks.txt index 955b087ed3..d3005d1c17 100644 --- a/test/prism/snapshots/blocks.txt +++ b/test/prism/snapshots/blocks.txt @@ -762,10 +762,7 @@ │ │ │ │ └── name: :bar │ │ │ ├── optionals: (length: 0) │ │ │ ├── rest: - │ │ │ │ @ RestParameterNode (location: (54,11)-(54,12)) - │ │ │ │ ├── name: ∅ - │ │ │ │ ├── name_loc: ∅ - │ │ │ │ └── operator_loc: (54,11)-(54,12) = "," + │ │ │ │ @ ImplicitRestNode (location: (54,11)-(54,12)) │ │ │ ├── posts: (length: 0) │ │ │ ├── keywords: (length: 0) │ │ │ ├── keyword_rest: ∅ diff --git a/test/prism/snapshots/seattlerb/bug236.txt b/test/prism/snapshots/seattlerb/bug236.txt index 0d9427bfff..a6ee09e21a 100644 --- a/test/prism/snapshots/seattlerb/bug236.txt +++ b/test/prism/snapshots/seattlerb/bug236.txt @@ -23,10 +23,7 @@ │ │ │ │ │ └── name: :a │ │ │ │ ├── optionals: (length: 0) │ │ │ │ ├── rest: - │ │ │ │ │ @ RestParameterNode (location: (1,4)-(1,5)) - │ │ │ │ │ ├── name: ∅ - │ │ │ │ │ ├── name_loc: ∅ - │ │ │ │ │ └── operator_loc: (1,4)-(1,5) = "," + │ │ │ │ │ @ ImplicitRestNode (location: (1,4)-(1,5)) │ │ │ │ ├── posts: (length: 0) │ │ │ │ ├── keywords: (length: 0) │ │ │ │ ├── keyword_rest: ∅ diff --git a/test/prism/snapshots/seattlerb/masgn_command_call.txt b/test/prism/snapshots/seattlerb/masgn_command_call.txt index ceb81c0500..7a7b26b9c3 100644 --- a/test/prism/snapshots/seattlerb/masgn_command_call.txt +++ b/test/prism/snapshots/seattlerb/masgn_command_call.txt @@ -9,9 +9,7 @@ │ ├── name: :a │ └── depth: 0 ├── rest: - │ @ SplatNode (location: (1,1)-(1,2)) - │ ├── operator_loc: (1,1)-(1,2) = "," - │ └── expression: ∅ + │ @ ImplicitRestNode (location: (1,1)-(1,2)) ├── rights: (length: 0) ├── lparen_loc: ∅ ├── rparen_loc: ∅ diff --git a/test/prism/snapshots/seattlerb/parse_pattern_051.txt b/test/prism/snapshots/seattlerb/parse_pattern_051.txt index fb9c3ee282..6067c109e1 100644 --- a/test/prism/snapshots/seattlerb/parse_pattern_051.txt +++ b/test/prism/snapshots/seattlerb/parse_pattern_051.txt @@ -26,7 +26,8 @@ │ │ │ │ └── flags: decimal │ │ │ └── @ IntegerNode (location: (2,7)-(2,8)) │ │ │ └── flags: decimal - │ │ ├── rest: ∅ + │ │ ├── rest: + │ │ │ @ ImplicitRestNode (location: (2,8)-(2,9)) │ │ ├── posts: (length: 0) │ │ ├── opening_loc: (2,3)-(2,4) = "[" │ │ └── closing_loc: (2,9)-(2,10) = "]" diff --git a/test/prism/snapshots/unparser/corpus/literal/assignment.txt b/test/prism/snapshots/unparser/corpus/literal/assignment.txt index ebb343a002..7890d308b2 100644 --- a/test/prism/snapshots/unparser/corpus/literal/assignment.txt +++ b/test/prism/snapshots/unparser/corpus/literal/assignment.txt @@ -39,9 +39,7 @@ │ │ │ │ ├── name: :a │ │ │ │ └── depth: 0 │ │ │ ├── rest: - │ │ │ │ @ SplatNode (location: (3,3)-(3,4)) - │ │ │ │ ├── operator_loc: (3,3)-(3,4) = "," - │ │ │ │ └── expression: ∅ + │ │ │ │ @ ImplicitRestNode (location: (3,3)-(3,4)) │ │ │ ├── rights: (length: 0) │ │ │ ├── lparen_loc: (3,1)-(3,2) = "(" │ │ │ └── rparen_loc: (3,4)-(3,5) = ")" @@ -274,9 +272,7 @@ │ │ ├── name: :a │ │ └── depth: 0 │ ├── rest: - │ │ @ SplatNode (location: (13,2)-(13,3)) - │ │ ├── operator_loc: (13,2)-(13,3) = "," - │ │ └── expression: ∅ + │ │ @ ImplicitRestNode (location: (13,2)-(13,3)) │ ├── rights: (length: 0) │ ├── lparen_loc: (13,0)-(13,1) = "(" │ ├── rparen_loc: (13,3)-(13,4) = ")" diff --git a/test/prism/snapshots/unparser/corpus/literal/block.txt b/test/prism/snapshots/unparser/corpus/literal/block.txt index 76d51d709e..11f92dd01b 100644 --- a/test/prism/snapshots/unparser/corpus/literal/block.txt +++ b/test/prism/snapshots/unparser/corpus/literal/block.txt @@ -72,10 +72,7 @@ │ │ │ │ │ └── name: :a │ │ │ │ ├── optionals: (length: 0) │ │ │ │ ├── rest: - │ │ │ │ │ @ RestParameterNode (location: (5,8)-(5,9)) - │ │ │ │ │ ├── name: ∅ - │ │ │ │ │ ├── name_loc: ∅ - │ │ │ │ │ └── operator_loc: (5,8)-(5,9) = "," + │ │ │ │ │ @ ImplicitRestNode (location: (5,8)-(5,9)) │ │ │ │ ├── posts: (length: 0) │ │ │ │ ├── keywords: (length: 0) │ │ │ │ ├── keyword_rest: ∅ @@ -108,10 +105,7 @@ │ │ │ │ │ └── name: :a │ │ │ │ ├── optionals: (length: 0) │ │ │ │ ├── rest: - │ │ │ │ │ @ RestParameterNode (location: (7,8)-(7,9)) - │ │ │ │ │ ├── name: ∅ - │ │ │ │ │ ├── name_loc: ∅ - │ │ │ │ │ └── operator_loc: (7,8)-(7,9) = "," + │ │ │ │ │ @ ImplicitRestNode (location: (7,8)-(7,9)) │ │ │ │ ├── posts: (length: 0) │ │ │ │ ├── keywords: (length: 0) │ │ │ │ ├── keyword_rest: ∅ diff --git a/test/prism/snapshots/unparser/corpus/literal/pattern.txt b/test/prism/snapshots/unparser/corpus/literal/pattern.txt index 88a191a334..983ec43050 100644 --- a/test/prism/snapshots/unparser/corpus/literal/pattern.txt +++ b/test/prism/snapshots/unparser/corpus/literal/pattern.txt @@ -54,7 +54,8 @@ │ │ │ │ │ │ └── flags: decimal │ │ │ │ │ └── @ IntegerNode (location: (4,7)-(4,8)) │ │ │ │ │ └── flags: decimal - │ │ │ │ ├── rest: ∅ + │ │ │ │ ├── rest: + │ │ │ │ │ @ ImplicitRestNode (location: (4,8)-(4,9)) │ │ │ │ ├── posts: (length: 0) │ │ │ │ ├── opening_loc: (4,3)-(4,4) = "[" │ │ │ │ └── closing_loc: (4,10)-(4,11) = "]" diff --git a/test/prism/snapshots/variables.txt b/test/prism/snapshots/variables.txt index 887b2a1b47..6930d43b25 100644 --- a/test/prism/snapshots/variables.txt +++ b/test/prism/snapshots/variables.txt @@ -199,9 +199,7 @@ │ │ ├── name: :foo │ │ └── depth: 0 │ ├── rest: - │ │ @ SplatNode (location: (35,3)-(35,4)) - │ │ ├── operator_loc: (35,3)-(35,4) = "," - │ │ └── expression: ∅ + │ │ @ ImplicitRestNode (location: (35,3)-(35,4)) │ ├── rights: (length: 0) │ ├── lparen_loc: ∅ │ ├── rparen_loc: ∅ diff --git a/test/prism/snapshots/whitequark/blockargs.txt b/test/prism/snapshots/whitequark/blockargs.txt index 150d02bf7a..9e579bee86 100644 --- a/test/prism/snapshots/whitequark/blockargs.txt +++ b/test/prism/snapshots/whitequark/blockargs.txt @@ -598,10 +598,7 @@ │ │ │ │ │ └── name: :b │ │ │ │ ├── optionals: (length: 0) │ │ │ │ ├── rest: - │ │ │ │ │ @ RestParameterNode (location: (37,8)-(37,9)) - │ │ │ │ │ ├── name: ∅ - │ │ │ │ │ ├── name_loc: ∅ - │ │ │ │ │ └── operator_loc: (37,8)-(37,9) = "," + │ │ │ │ │ @ ImplicitRestNode (location: (37,8)-(37,9)) │ │ │ │ ├── posts: (length: 0) │ │ │ │ ├── keywords: (length: 0) │ │ │ │ ├── keyword_rest: ∅ @@ -859,10 +856,7 @@ │ │ │ │ │ └── name: :a │ │ │ │ ├── optionals: (length: 0) │ │ │ │ ├── rest: - │ │ │ │ │ @ RestParameterNode (location: (49,5)-(49,6)) - │ │ │ │ │ ├── name: ∅ - │ │ │ │ │ ├── name_loc: ∅ - │ │ │ │ │ └── operator_loc: (49,5)-(49,6) = "," + │ │ │ │ │ @ ImplicitRestNode (location: (49,5)-(49,6)) │ │ │ │ ├── posts: (length: 0) │ │ │ │ ├── keywords: (length: 0) │ │ │ │ ├── keyword_rest: ∅ diff --git a/test/prism/snapshots/whitequark/masgn_nested.txt b/test/prism/snapshots/whitequark/masgn_nested.txt index e716762a98..d9513e5813 100644 --- a/test/prism/snapshots/whitequark/masgn_nested.txt +++ b/test/prism/snapshots/whitequark/masgn_nested.txt @@ -11,9 +11,7 @@ │ │ │ ├── name: :b │ │ │ └── depth: 0 │ │ ├── rest: - │ │ │ @ SplatNode (location: (1,3)-(1,4)) - │ │ │ ├── operator_loc: (1,3)-(1,4) = "," - │ │ │ └── expression: ∅ + │ │ │ @ ImplicitRestNode (location: (1,3)-(1,4)) │ │ ├── rights: (length: 0) │ │ ├── lparen_loc: (1,1)-(1,2) = "(" │ │ └── rparen_loc: (1,5)-(1,6) = ")" |