Skip to content

Commit

Permalink
Fix end location of call with block arg and no parentheses
Browse files Browse the repository at this point in the history
  • Loading branch information
FnControlOption committed Feb 22, 2025
1 parent c29083a commit 9679f1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions spec/compiler/parser/parser_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2372,6 +2372,10 @@ module Crystal
assert_end_location "1 ensure 2"
assert_end_location "foo.bar= *baz"
assert_end_location %("hello "\\\n"world"), line_number: 2, column_number: 7
assert_end_location "foo(&.bar)"
assert_end_location "foo &.bar"
assert_end_location "foo(&bar)"
assert_end_location "foo &bar"

assert_syntax_error %({"a" : 1}), "space not allowed between named argument name and ':'"
assert_syntax_error %({"a": 1, "b" : 2}), "space not allowed between named argument name and ':'"
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/crystal/syntax/parser.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1587,12 +1587,12 @@ module Crystal
call ||= parse_call_block_arg_after_dot(obj)

block = Block.new([Var.new(block_arg_name)], call).at(location)
end_location = call.end_location
else
block_arg = parse_op_assign
end_location = block_arg.end_location
end

end_location = token_end_location

if check_paren
skip_space_or_newline
check :OP_RPAREN
Expand Down

0 comments on commit 9679f1e

Please sign in to comment.