diff --git a/spec/ameba/rule/style/redundant_begin_spec.cr b/spec/ameba/rule/style/redundant_begin_spec.cr index 5e0fd465..d50c324d 100644 --- a/spec/ameba/rule/style/redundant_begin_spec.cr +++ b/spec/ameba/rule/style/redundant_begin_spec.cr @@ -192,6 +192,19 @@ module Ameba::Rule::Style subject.catch(s).should_not be_valid end + it "doesn't report if begin-end block in a proc literal" do + s = Source.new %q( + foo = ->{ + begin + raise "Foo!" + rescue ex + pp ex + end + } + ) + subject.catch(s).should be_valid + end + it "reports rule, pos and message" do s = Source.new %q( def method diff --git a/src/ameba/rule/style/redundant_begin.cr b/src/ameba/rule/style/redundant_begin.cr index c4a60940..df5bd621 100644 --- a/src/ameba/rule/style/redundant_begin.cr +++ b/src/ameba/rule/style/redundant_begin.cr @@ -113,7 +113,7 @@ module Ameba::Rule::Style token = lexer.next_token case token.type - when :EOF + when :EOF, :"->" break when :IDENT return token.value == :begin if in_body?