diff --git a/spec/compiler/parser/parser_spec.cr b/spec/compiler/parser/parser_spec.cr index 69ac1ab452da..faee7516d728 100644 --- a/spec/compiler/parser/parser_spec.cr +++ b/spec/compiler/parser/parser_spec.cr @@ -2806,8 +2806,10 @@ module Crystal then_node_location = then_node.expressions[1].location.should_not be_nil then_node_location.line_number.should eq 2 + then_node_location.column_number.should eq 5 then_node_location = then_node.expressions[1].end_location.should_not be_nil then_node_location.line_number.should eq 2 + then_node_location.column_number.should eq 13 else_node = node.else.should be_a Expressions else_node_location = else_node.location.should_not be_nil diff --git a/src/compiler/crystal/syntax/parser.cr b/src/compiler/crystal/syntax/parser.cr index 64e97e320aa8..7896aa2026a4 100644 --- a/src/compiler/crystal/syntax/parser.cr +++ b/src/compiler/crystal/syntax/parser.cr @@ -3228,9 +3228,11 @@ module Crystal when .macro_literal? pieces << MacroLiteral.new(@token.value.to_s).at(@token.location).at_end(token_end_location) when .macro_expression_start? - pieces << MacroExpression.new(parse_macro_expression).at(@token.location).at_end(token_end_location) + location = @token.location + exp = MacroExpression.new(parse_macro_expression).at(location) check_macro_expression_end skip_whitespace = check_macro_skip_whitespace + pieces << exp.at_end(token_end_location) when .macro_control_start? macro_control = parse_macro_control(start_location, macro_state) if macro_control