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

Standard Interpolator should call process, not treatEscapes #6559

Closed
scabug opened this issue Oct 22, 2012 · 8 comments
Closed

Standard Interpolator should call process, not treatEscapes #6559

scabug opened this issue Oct 22, 2012 · 8 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Oct 22, 2012

Just looking at the source for StringContext. In the 'while (ai.hasNext)' loop, it calls treatEscapes. I think it should call the 'process' function passed in as a parameter.

@scabug
Copy link
Author

scabug commented Oct 22, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6559?orig=1
Reporter: Curtis Stanford (countfloyd)
Other Milestones: 2.10.0

@scabug
Copy link
Author

scabug commented Oct 23, 2012

@jsuereth said:
For refrence:

def standardInterpolator(process: String => String, args: Seq[Any]): String = {
    checkLengths(args)
    val pi = parts.iterator
    val ai = args.iterator
    val bldr = new java.lang.StringBuilder(process(pi.next()))
    while (ai.hasNext) {
      bldr append ai.next
      bldr append treatEscapes(pi.next())
    }
    bldr.toString
  }

This means that the raw interpolator does not work correctly:

  def raw(args: Any*): String = standardInterpolator(identity, args)

@scabug
Copy link
Author

scabug commented Nov 5, 2012

Jan Niehusmann (jannic) said:
Stumbled across this bug just minutes after starting to play with 2.10.0-RC2:

scala> val x = "x"
x: String = x

scala> raw"\n$x\n"
res1: String = 
"\nx
"

It seems like there is a patch already committed (0b7aaa5 by Julien Richard-Foy), which is on the master branch, but not in 2.10.0-RC2.

@scabug
Copy link
Author

scabug commented Nov 6, 2012

@jsuereth said:
This was already reported and fixed in 2.10.x branch. Since this was found during the RC cycle, and there is a workaround (defining your own raw interpolator) the fix is delayed until the 2.10.1 release in Feb. Sorry for any inconvenience.

@scabug
Copy link
Author

scabug commented Nov 7, 2012

@Ichoran said:
Please change the docs on raw to state that it is broken if it's not going to be fixed for .0. The first thing I did with raw was not raw, which was (1) confusing given that there was no documentation and (2) would not inspire a lot of confidence in me for using a .0 release if I wasn't following the dev process and tried this early.

@scabug
Copy link
Author

scabug commented Nov 10, 2012

@retronym said:
Josh: I don't see how we can change the semantics in a dot-one release (or any other release, really.) IMO, we should remove it or fix it.

@scabug
Copy link
Author

scabug commented Nov 11, 2012

@odersky said:
Jason: We can change the semantics if we clearly state it in the release note or the doc comment. That said I am also OK in fixing it now, if there is to be another RC. Not having an opinion for or against.

@scabug
Copy link
Author

scabug commented Nov 13, 2012

@retronym said:
Reopening for backport to 2.10.0

scala/scala#1616

@scabug scabug closed this as completed Nov 16, 2012
@scabug scabug added the has PR label Apr 7, 2017
@scabug scabug added this to the 2.10.0-RC2 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants