-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Multiline string normalization on windows is inconsistent #11988
Comments
This first line bug should probably be fixed. Otherwise, use |
Should the Julia parser normalize source code so that line endings in string literals are always |
I would think so. If you need |
Yes I prefer that julia normalize multiline string literals so that lines always end in |
This is not just """, but also " (because those can be multiline also, """ is just about dedenting). |
True. |
Agree on the normalization. Just wanted to clarify that it's not just a problem because of broken editors on Windows. In this case I just copied the code from the browser to quickly try it out, so there was no |
Git's |
ref Lines 413 to 414 in b6ae1df
|
Strip a leading "\r\n" or "\n" from triple-quoted strings.
I've pushed a fix for the leading newline issue.
Agreed. |
However, this is program source, not an arbitrary text file. |
Python seems to normalize all newlines to
I agree that it seems sensible for us to do the same. |
Bump. This came up on julia-users: https://groups.google.com/forum/#!topic/julia-users/N3dgCaT1WYo. |
I should have a PR shortly. |
For completeness, do we also want to interpret all of the Unicode newlines as I've never seen any of the others "in the wild", so I'm not sure what to do about them. (Python doesn't touch anything but CR and CRLF as far as I can tell; the others are left unchanged.) |
I would just make the occurrence of any of the other newlines in Julia source a syntax error. If you want one, you can always use an escape sequence, and anything else just seems to ask for confusion. I would require |
In addition, it might be nice to throw an exception for any |
Seems like a good idea. |
The following code results in inconsistent line endings and first line normalization on windows:
Result (explicitly writing all nonprintable characters):
The fact that the first blank line isn't removed as it would be on linux is inconsistent. The underlying issue seems to be that a multiline string gets whatever line endings happen to exist in the source file. Unfortunately this makes multiline strings a bit useless for writing consistent text files on windows, and can lead to some of the more pedantic file parsers rejecting files outright (As recently encountered in the wild by @visr - see discussion on c42f/displaz#40).
Of course, if the julia code above is distributed to windows users with unix line endings the problem won't occur, but windows programs have an annoying habit of "helpfully" converting things (eg, see git.autocrlf). Given this, I think the only sensible option is to normalize multiline strings to the One True Line Ending of
"\n"
during parsing.See also #3946, which was the only other place I found this mentioned.
The text was updated successfully, but these errors were encountered: