usethesource / rascal

The implementation of the Rascal meta-programming language (including interpreter, type checker, parser generator, compiler and JVM based run-time system)
http://www.rascal-mpl.org
Other
396 stars 77 forks source link

Multi-line strings are not platform-independent #1119

Open rodinaarssen opened 6 years ago

rodinaarssen commented 6 years ago
str s = "bla
        'bla";
bool crlf() = s == "bla\r\nbla";    
bool lf() = s == "bla\nbla"; 
rascal>crlf()
bool: true
rascal>lf()
bool: false

Multi-line strings are not platform-independent; in other words: depending on the platform, either "\r\n" or "\n" is inserted into the character array. This causes some tests to fail while building Rascal, as I found out while working on #1118.

JJWTimmer commented 6 years ago

Just browsing this repo tonight as an old user... I saw the same behaviour with scala multiline strings. This is the editor inserting the \r\n or \n, probably because the editor is not configured to always use linux line endings (\n) and/or git does the autocrlf magic if you only checked out and did not modify the file. With other words, I guess this is by design. Just my two cents 😄

PaulKlint commented 6 years ago

Hi @JJWTimmer, this is a very useful observation. It probably means that we have to be more careful when parsing multiline string literals and probably change every \r\n into \n. Thanks again for pointing this out.