Skip to content

Commit f665731

Browse files
authored
Merge pull request #134 from vinistock/vs/consume_end_on_rescue_and_ensure
Consume end tokens on begins with rescue or ensure
2 parents 3ecc988 + d1ff2cf commit f665731

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/syntax_tree/parser.rb

+1-2
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

+8
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)