diff --git a/src/compiler/crystal/syntax/parser.cr b/src/compiler/crystal/syntax/parser.cr index 6018c6a1e1db..e491c11d009a 100644 --- a/src/compiler/crystal/syntax/parser.cr +++ b/src/compiler/crystal/syntax/parser.cr @@ -2834,7 +2834,9 @@ module Crystal when_body = parse_expressions skip_space_or_newline - whens << When.new(when_conds, when_body).at(location) + whens << When.new(when_conds, when_body) + .at(location) + .at_end(when_conds.last.end_location) when Keyword::ELSE if exhaustive raise "exhaustive case (case ... in) doesn't allow an 'else'" @@ -2990,6 +2992,8 @@ module Crystal skip_space_or_newline whens << When.new(condition, body) + .at(location) + .at_end(condition.end_location) when Keyword::ELSE if whens.size == 0 unexpected_token "expecting when"