Skip to content

Call#end_line_column off by one if last argument is named and parentheses omitted #16092

@HertzDevil

Description

@HertzDevil

f(foo x: 123) below reports the incorrect end column number, which coincides with the ) of the outer macro call:

macro f(x)
  {% p x.end_column_number %}
end

f(foo()) # => 7
f(foo)   # => 5

f(foo(123)) # => 10
f(foo 123)  # => 9

f(foo(x: 123)) # => 13
f(foo x: 123)  # => 13

f(foo(x: 123, &.bar)) # => 20
f(foo x: 123, &.bar)  # => 19

If f itself has no parentheses, the end location advances to one character before the next node:

macro f(x)
  {% p [x.end_line_number, x.end_column_number] %}
end

f foo(x: 123) # => [5, 13]
f foo x: 123  # => [8, 0]

f foo(x: 123, &.bar) # => [8, 20]
f foo x: 123, &.bar  # => [9, 19]

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:bugA bug in the code. Does not apply to documentation, specs, etc.topic:compiler:parser

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions