Skip to content

Commit cbbc8ad

Browse files
authored
Merge pull request #397 from viralpraxis/fix-resbody-without-body-unparsing
Fix `rescue` without body unparsing
2 parents ad33ee8 + e90ee27 commit cbbc8ad

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

lib/unparser/writer/resbody.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Resbody
1515

1616
def emit_postcontrol
1717
write(' rescue ')
18-
visit(body)
18+
visit(body) if body
1919
end
2020

2121
def emit_regular

lib/unparser/writer/rescue.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def emit_regular
2121
end
2222

2323
def emit_postcontrol
24-
visit(body)
24+
visit(body) if body
2525
writer_with(Resbody, node: rescue_body).emit_postcontrol
2626
end
2727

test/corpus/semantic/rescue.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ class << self
1010
ensure
1111
end
1212
end
13+
module A
14+
rescue
15+
end
1316
begin; rescue => A[1]; end
1417
begin; rescue => A[1, 2]; end
1518
begin; rescue => A[1, 2, 3]; end

0 commit comments

Comments
 (0)