summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2025-01-22 14:18:58 -0500
committergit <svn-admin@ruby-lang.org>2025-01-22 19:58:27 +0000
commitc2908613368b2ae404d094a15df61d830fc46dc9 (patch)
treea7da85b3d908004ca2abde205a7329223895e400 /test
parent241ada7b1ca4fd71dc47a83d912ee25162a555d9 (diff)
[ruby/prism] Fix rescue modifier precedence
Fixes [Bug #21048] https://github.com/ruby/prism/commit/07202005cb
Diffstat (limited to 'test')
-rw-r--r--test/prism/fixtures/rescue_modifier.txt7
-rw-r--r--test/prism/snapshots/rescue_modifier.txt230
2 files changed, 237 insertions, 0 deletions
diff --git a/test/prism/fixtures/rescue_modifier.txt b/test/prism/fixtures/rescue_modifier.txt
new file mode 100644
index 0000000000..def9e2dbed
--- /dev/null
+++ b/test/prism/fixtures/rescue_modifier.txt
@@ -0,0 +1,7 @@
+a rescue b if c
+
+a = b rescue c if d
+
+a, = b rescue c if d
+
+def a = b rescue c if d
diff --git a/test/prism/snapshots/rescue_modifier.txt b/test/prism/snapshots/rescue_modifier.txt
new file mode 100644
index 0000000000..0a27a3bb49
--- /dev/null
+++ b/test/prism/snapshots/rescue_modifier.txt
@@ -0,0 +1,230 @@
+@ ProgramNode (location: (1,0)-(7,23))
+├── flags: ∅
+├── locals: [:a]
+└── statements:
+ @ StatementsNode (location: (1,0)-(7,23))
+ ├── flags: ∅
+ └── body: (length: 4)
+ ├── @ IfNode (location: (1,0)-(1,15))
+ │ ├── flags: newline
+ │ ├── if_keyword_loc: (1,11)-(1,13) = "if"
+ │ ├── predicate:
+ │ │ @ CallNode (location: (1,14)-(1,15))
+ │ │ ├── flags: variable_call, ignore_visibility
+ │ │ ├── receiver: ∅
+ │ │ ├── call_operator_loc: ∅
+ │ │ ├── name: :c
+ │ │ ├── message_loc: (1,14)-(1,15) = "c"
+ │ │ ├── opening_loc: ∅
+ │ │ ├── arguments: ∅
+ │ │ ├── closing_loc: ∅
+ │ │ └── block: ∅
+ │ ├── then_keyword_loc: ∅
+ │ ├── statements:
+ │ │ @ StatementsNode (location: (1,0)-(1,10))
+ │ │ ├── flags: ∅
+ │ │ └── body: (length: 1)
+ │ │ └── @ RescueModifierNode (location: (1,0)-(1,10))
+ │ │ ├── flags: newline
+ │ │ ├── expression:
+ │ │ │ @ CallNode (location: (1,0)-(1,1))
+ │ │ │ ├── flags: variable_call, ignore_visibility
+ │ │ │ ├── receiver: ∅
+ │ │ │ ├── call_operator_loc: ∅
+ │ │ │ ├── name: :a
+ │ │ │ ├── message_loc: (1,0)-(1,1) = "a"
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── arguments: ∅
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── block: ∅
+ │ │ ├── keyword_loc: (1,2)-(1,8) = "rescue"
+ │ │ └── rescue_expression:
+ │ │ @ CallNode (location: (1,9)-(1,10))
+ │ │ ├── flags: variable_call, ignore_visibility
+ │ │ ├── receiver: ∅
+ │ │ ├── call_operator_loc: ∅
+ │ │ ├── name: :b
+ │ │ ├── message_loc: (1,9)-(1,10) = "b"
+ │ │ ├── opening_loc: ∅
+ │ │ ├── arguments: ∅
+ │ │ ├── closing_loc: ∅
+ │ │ └── block: ∅
+ │ ├── subsequent: ∅
+ │ └── end_keyword_loc: ∅
+ ├── @ IfNode (location: (3,0)-(3,19))
+ │ ├── flags: newline
+ │ ├── if_keyword_loc: (3,15)-(3,17) = "if"
+ │ ├── predicate:
+ │ │ @ CallNode (location: (3,18)-(3,19))
+ │ │ ├── flags: variable_call, ignore_visibility
+ │ │ ├── receiver: ∅
+ │ │ ├── call_operator_loc: ∅
+ │ │ ├── name: :d
+ │ │ ├── message_loc: (3,18)-(3,19) = "d"
+ │ │ ├── opening_loc: ∅
+ │ │ ├── arguments: ∅
+ │ │ ├── closing_loc: ∅
+ │ │ └── block: ∅
+ │ ├── then_keyword_loc: ∅
+ │ ├── statements:
+ │ │ @ StatementsNode (location: (3,0)-(3,14))
+ │ │ ├── flags: ∅
+ │ │ └── body: (length: 1)
+ │ │ └── @ LocalVariableWriteNode (location: (3,0)-(3,14))
+ │ │ ├── flags: newline
+ │ │ ├── name: :a
+ │ │ ├── depth: 0
+ │ │ ├── name_loc: (3,0)-(3,1) = "a"
+ │ │ ├── value:
+ │ │ │ @ RescueModifierNode (location: (3,4)-(3,14))
+ │ │ │ ├── flags: ∅
+ │ │ │ ├── expression:
+ │ │ │ │ @ CallNode (location: (3,4)-(3,5))
+ │ │ │ │ ├── flags: variable_call, ignore_visibility
+ │ │ │ │ ├── receiver: ∅
+ │ │ │ │ ├── call_operator_loc: ∅
+ │ │ │ │ ├── name: :b
+ │ │ │ │ ├── message_loc: (3,4)-(3,5) = "b"
+ │ │ │ │ ├── opening_loc: ∅
+ │ │ │ │ ├── arguments: ∅
+ │ │ │ │ ├── closing_loc: ∅
+ │ │ │ │ └── block: ∅
+ │ │ │ ├── keyword_loc: (3,6)-(3,12) = "rescue"
+ │ │ │ └── rescue_expression:
+ │ │ │ @ CallNode (location: (3,13)-(3,14))
+ │ │ │ ├── flags: variable_call, ignore_visibility
+ │ │ │ ├── receiver: ∅
+ │ │ │ ├── call_operator_loc: ∅
+ │ │ │ ├── name: :c
+ │ │ │ ├── message_loc: (3,13)-(3,14) = "c"
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── arguments: ∅
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── block: ∅
+ │ │ └── operator_loc: (3,2)-(3,3) = "="
+ │ ├── subsequent: ∅
+ │ └── end_keyword_loc: ∅
+ ├── @ IfNode (location: (5,0)-(5,20))
+ │ ├── flags: newline
+ │ ├── if_keyword_loc: (5,16)-(5,18) = "if"
+ │ ├── predicate:
+ │ │ @ CallNode (location: (5,19)-(5,20))
+ │ │ ├── flags: variable_call, ignore_visibility
+ │ │ ├── receiver: ∅
+ │ │ ├── call_operator_loc: ∅
+ │ │ ├── name: :d
+ │ │ ├── message_loc: (5,19)-(5,20) = "d"
+ │ │ ├── opening_loc: ∅
+ │ │ ├── arguments: ∅
+ │ │ ├── closing_loc: ∅
+ │ │ └── block: ∅
+ │ ├── then_keyword_loc: ∅
+ │ ├── statements:
+ │ │ @ StatementsNode (location: (5,0)-(5,15))
+ │ │ ├── flags: ∅
+ │ │ └── body: (length: 1)
+ │ │ └── @ MultiWriteNode (location: (5,0)-(5,15))
+ │ │ ├── flags: newline
+ │ │ ├── lefts: (length: 1)
+ │ │ │ └── @ LocalVariableTargetNode (location: (5,0)-(5,1))
+ │ │ │ ├── flags: ∅
+ │ │ │ ├── name: :a
+ │ │ │ └── depth: 0
+ │ │ ├── rest:
+ │ │ │ @ ImplicitRestNode (location: (5,1)-(5,2))
+ │ │ │ └── flags: ∅
+ │ │ ├── rights: (length: 0)
+ │ │ ├── lparen_loc: ∅
+ │ │ ├── rparen_loc: ∅
+ │ │ ├── operator_loc: (5,3)-(5,4) = "="
+ │ │ └── value:
+ │ │ @ RescueModifierNode (location: (5,5)-(5,15))
+ │ │ ├── flags: ∅
+ │ │ ├── expression:
+ │ │ │ @ CallNode (location: (5,5)-(5,6))
+ │ │ │ ├── flags: variable_call, ignore_visibility
+ │ │ │ ├── receiver: ∅
+ │ │ │ ├── call_operator_loc: ∅
+ │ │ │ ├── name: :b
+ │ │ │ ├── message_loc: (5,5)-(5,6) = "b"
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── arguments: ∅
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── block: ∅
+ │ │ ├── keyword_loc: (5,7)-(5,13) = "rescue"
+ │ │ └── rescue_expression:
+ │ │ @ CallNode (location: (5,14)-(5,15))
+ │ │ ├── flags: variable_call, ignore_visibility
+ │ │ ├── receiver: ∅
+ │ │ ├── call_operator_loc: ∅
+ │ │ ├── name: :c
+ │ │ ├── message_loc: (5,14)-(5,15) = "c"
+ │ │ ├── opening_loc: ∅
+ │ │ ├── arguments: ∅
+ │ │ ├── closing_loc: ∅
+ │ │ └── block: ∅
+ │ ├── subsequent: ∅
+ │ └── end_keyword_loc: ∅
+ └── @ IfNode (location: (7,0)-(7,23))
+ ├── flags: newline
+ ├── if_keyword_loc: (7,19)-(7,21) = "if"
+ ├── predicate:
+ │ @ CallNode (location: (7,22)-(7,23))
+ │ ├── flags: variable_call, ignore_visibility
+ │ ├── receiver: ∅
+ │ ├── call_operator_loc: ∅
+ │ ├── name: :d
+ │ ├── message_loc: (7,22)-(7,23) = "d"
+ │ ├── opening_loc: ∅
+ │ ├── arguments: ∅
+ │ ├── closing_loc: ∅
+ │ └── block: ∅
+ ├── then_keyword_loc: ∅
+ ├── statements:
+ │ @ StatementsNode (location: (7,0)-(7,18))
+ │ ├── flags: ∅
+ │ └── body: (length: 1)
+ │ └── @ DefNode (location: (7,0)-(7,18))
+ │ ├── flags: newline
+ │ ├── name: :a
+ │ ├── name_loc: (7,4)-(7,5) = "a"
+ │ ├── receiver: ∅
+ │ ├── parameters: ∅
+ │ ├── body:
+ │ │ @ StatementsNode (location: (7,8)-(7,18))
+ │ │ ├── flags: ∅
+ │ │ └── body: (length: 1)
+ │ │ └── @ RescueModifierNode (location: (7,8)-(7,18))
+ │ │ ├── flags: ∅
+ │ │ ├── expression:
+ │ │ │ @ CallNode (location: (7,8)-(7,9))
+ │ │ │ ├── flags: variable_call, ignore_visibility
+ │ │ │ ├── receiver: ∅
+ │ │ │ ├── call_operator_loc: ∅
+ │ │ │ ├── name: :b
+ │ │ │ ├── message_loc: (7,8)-(7,9) = "b"
+ │ │ │ ├── opening_loc: ∅
+ │ │ │ ├── arguments: ∅
+ │ │ │ ├── closing_loc: ∅
+ │ │ │ └── block: ∅
+ │ │ ├── keyword_loc: (7,10)-(7,16) = "rescue"
+ │ │ └── rescue_expression:
+ │ │ @ CallNode (location: (7,17)-(7,18))
+ │ │ ├── flags: variable_call, ignore_visibility
+ │ │ ├── receiver: ∅
+ │ │ ├── call_operator_loc: ∅
+ │ │ ├── name: :c
+ │ │ ├── message_loc: (7,17)-(7,18) = "c"
+ │ │ ├── opening_loc: ∅
+ │ │ ├── arguments: ∅
+ │ │ ├── closing_loc: ∅
+ │ │ └── block: ∅
+ │ ├── locals: []
+ │ ├── def_keyword_loc: (7,0)-(7,3) = "def"
+ │ ├── operator_loc: ∅
+ │ ├── lparen_loc: ∅
+ │ ├── rparen_loc: ∅
+ │ ├── equal_loc: (7,6)-(7,7) = "="
+ │ └── end_keyword_loc: ∅
+ ├── subsequent: ∅
+ └── end_keyword_loc: ∅