Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d1ff2cf

Browse files
vinistockkddnewton
andcommitted
Consume end tokens on begins with rescue or ensure
Co-authored-by: Kevin Newton <kddnewton@users.noreply.github.com>
1 parent 3ecc988 commit d1ff2cf

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/syntax_tree/parser.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,8 +717,7 @@ def on_begin(bodystmt)
717717
else
718718
keyword = find_token(Kw, "begin")
719719
end_location =
720-
if bodystmt.rescue_clause || bodystmt.ensure_clause ||
721-
bodystmt.else_clause
720+
if bodystmt.else_clause
722721
bodystmt.location
723722
else
724723
find_token(Kw, "end").location

test/fixtures/def_endless.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,11 @@ def self.foo() = bar
1818
def self.foo = bar
1919
% # >= 3.1.0
2020
def self.foo = bar baz
21+
%
22+
begin
23+
true
24+
rescue StandardError
25+
false
26+
end
27+
28+
def foo? = true

0 commit comments

Comments
 (0)