From 852d6cc2ecca84c50c6451a0cdebd124b6f3318b Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Sat, 22 Feb 2025 12:43:36 +0100 Subject: [PATCH] Add missing locations to `When` nodes (#15481) --- src/compiler/crystal/syntax/parser.cr | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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"