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
Newlines in multiline strings are converted to \n #3101
Comments
Imported From: https://issues.scala-lang.org/browse/SI-3101?orig=1
|
@jrudolph said: What is your expectation for the Scala compiler to do when it finds special characters inside a multiline string? IMO it should just treat them verbatim and apply no processing to them whatsoever. |
Pavol Vaskovic (pali-at-pali.sk) said:
As written in original report:
Even though I am not sure what you mean by special characters, I would say the behavior should be same as in 2.7. Breaking changes in compiler need strong rationale, because they are very painful. |
@jrudolph said: I'll restate the problem: In 2.8 the Scala compiler handles newlines in multiline strings specially: The character sequence "\r\n" is replaced by "\n". This changed from 2.7 which IMO showed the correct behaviour: Multiline strings could contain any characters and were converted verbatim on the character-level into a string constant. The Scala langugage reference says: Characters must not necessarily be printable; newlines or other control characters are also permitted. Unicode escapes work as everywhere else, but none of the escape sequences in (�1.3.6) is interpreted. |
@jrudolph said: |
Pavol Vaskovic (pali-at-pali.sk) said: BTW, looking at the fix in r21017, I see no testcases committed. Are there any? |
@SethTisue said: |
@jrudolph said: The problem here is that version control systems like git automatically adapt line endings of source files to the OS they run on when checking code out or in. But maybe this kind of inadvertent "fuzzing" just demonstrates the real issue: that you need to be explicit about what kind of line endings a multiline string should produce in the first place. So, we actually like the |
On Windows, where line.separator is \r\n, the scala compiler 2.8.0.Beta1 converts the platform newlines in multiline strings to \n.
This is wrong.
Steps to reproduce:
Create nl.scala with:
Make sure it has Windows line separator \r\n.
scala-2.8.0.Beta1-prerelease:
scala nl.scala 1
Expected results (scala 2.7.7):
scala nl.scala 2
I was also able to reproduce this also with scala-2.8.0-20100214.025735-327 (latest from maven snaphots repo).
Specs way to reproduce:
Note you can force the windows line separators in file from SVN by setting the svn:eol-style property to CRLF.
The text was updated successfully, but these errors were encountered: