Skip to content

Wrong nameSpan in Select when using parentheses #16771

Closed
@jkciesluk

Description

@jkciesluk

Compiler version

3.2.2

Minimized code

val a = (1 + 2 + 3).toString

Output

Select(
  qualifier = Apply(
    fun = Select(
      qualifier = Apply(
        fun = Select(qualifier = Literal(const = ( = 1)), name = +),
        args = List(Literal(const = ( = 2)))
      ),
      name = +
    ),
    args = List(Literal(const = ( = 3)))
  ),
  name = toString
)
// select span
[8..20..28]
// qualifier span
<9..18>
// nameSpan (toString span)
[8..20..16]

Because qualifier.span.start > select.span.start, this is treated as right associative operator

Expectation

toString span would be correct, i.e. [20..20..28]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions