Scala Programming Language
  1. Scala Programming Language
  2. SI-7271

String interpolated parts get assigned with incorrect positions

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.0
    • Fix Version/s: Scala 2.10.2-RC1
    • Component/s: None

      Description

      Last login: Tue Mar 19 09:37:02 on ttys001
      09:37 ~$ 210x
      09:37 ~/Projects/210x (2.10.x)$ parse -Xprint-pos 's"foo${bar}baz"'
      [[syntax trees at end of parser]]// Scala source: tmpOh6bpd
      [6]package [6]<empty> {
        [6]class wrapper extends [14][33]scala.AnyRef {
          [14]def <init>() = [14]{
            [14][14][14]super.<init>();
            [14]()
          };
          [16][16][16][16]StringContext([16]"foo", [16]"baz").s([23]bar)
        }
      }
      PackageDef(Ident(newTermName("<empty>")), List(ClassDef(Modifiers(), newTypeName("wrapper"), List(), Template(List(Select(Ident(scala), newTypeName("AnyRef"))), emptyValDef, List(DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(())))), Apply(Select(Apply(Ident(newTermName("StringContext")), List(Literal(Constant("foo")), Literal(Constant("baz")))), newTermName("s")), List(Ident(newTermName("bar")))))))))
      

      Note the [16] tokens next to "foo" and "baz". They mean that all those three trees are considered to originate from the beginning of the interpolated string, which is incorrect.

        Activity

        Hide
        Eugene Burmako added a comment - - edited
        Show
        Eugene Burmako added a comment - - edited https://github.com/scala/scala/pull/2461
        Show
        Eugene Burmako added a comment - https://github.com/scalamacros/kepler/commit/a8edefcef8905ed3487c7293056f6d0946e79dd7

          People

          • Assignee:
            Eugene Burmako
            Reporter:
            Eugene Burmako
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development