Skip to content

String interpolation followed by a dot is missing string literals #15514

Closed
@tgodzik

Description

@tgodzik

Compiler version

3.2.0-RC1

Minimized code

object Main {
 s"Hello $Main.toStr!"
}

Output

This is the tree representing the string interpolation:

 Select(
    qualifier = Apply(
      fun = Select(
        qualifier = Apply(
          fun = Select(
            qualifier = Select(
              qualifier = Select(qualifier = Ident(name = _root_), name = scala),
              name = StringContext
            ),
            name = apply
          ),
          args = List(
            Typed(
              expr = SeqLiteral(
                elems = List(Literal(const = ( = "Hello "))),
                elemtpt = ...
              ),
              tpt = ...
            )
          )
        ),
        name = s
      ),
      args = List(
        ...
      )
    ),
    name = <error>
  ),

Notice it only contains "Hello " literal.

Expectation

 Select(
    qualifier = Apply(
      fun = Select(
        qualifier = Apply(
          fun = Select(
            qualifier = Select(
              qualifier = Select(qualifier = Ident(name = _root_), name = scala),
              name = StringContext
            ),
            name = apply
          ),
          args = List(
            Typed(
              expr = SeqLiteral(
                 elems = List(Literal(const = ( = "Hello ")), Literal(const = ( = ".toStr!")))
                elemtpt = ...
              ),
              tpt = ...
            )
          )
        ),
        name = s
      ),
      args = List(
        ...
      )
    ),
    name = <error>
  ),

The main part is elems = List(Literal(const = ( = "Hello ")), Literal(const = ( = ".toStr!")))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions