Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix end location of call with block arg and no parentheses #15502

Merged
merged 1 commit into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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