-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
parsing failure on windows #9257
Comments
I can reproduce the issue on a Linux system, provided that I save the file with DOS newlines (CR+LF). Likely the lexer is choking on the unexpected CR. Easy steps to reproduce:
|
A patch as simple as this seems to make the tokenizer happy:
I'll see if there's any tests where I can record the regression and send a PR out for review. |
Fixes ziglang#9257. This is needed when tokenizing input containing DOS line endings, i.e. the CRLF sequence.
Fixes ziglang#9257. This is needed when tokenizing input containing DOS line endings, i.e. the CRLF sequence.
I have the same issue on |
Fixes ziglang#9257. This is needed when tokenizing input containing DOS line endings, i.e. the CRLF sequence.
Fixes #9257. This is needed when tokenizing input containing DOS line endings, i.e. the CRLF sequence.
Thanks for the patch @jmc-88, however I reverted it because this was working as designed. Carriage returns are discouraged in general, removed by |
See ziglang/zig-spec#38 for clarification. I opened an issue because the draft spec and the current compiler implementation do not match up exactly; this issue has the canonical specification. |
If no CRs are allowed in multi-line string literals, does this mean it's impossible to include multi-line string literals in source files with DOS newlines without an editor plugin? |
I'm not sure what you mean about an editor plugin, but yes, if you need a string with DOS newlines, it would require a strategy such as:
|
I mean, if my source file was saved with DOS newlines and it includes multiline strings, the newlines in them would become CRLF and thus rejected by the compiler, as in this issue. But I don't mean to verbatim include those CRLFs in my string, I just want them to be standard I know language such as Javascript accepts all styles of newlines in multiline string literals, but they will get converted to |
OK, but then looking at ziglang/zig-spec#38, In any case, if certain bytes are disallowed it may help to improve the error message to point out which invalid bytes were found and rejected.
I think what @andrewrk suggests is that you need to apply |
I just got back to this. My issue is that git on windows has |
Also, I can't run
|
|
This has really sent me down a rabbit hole trying to get certain repositories to work on Windows! I think this is one of those times where striving for simplicity is actually making things harder in certain cases. It's quite a subtle thing to try and debug for someone not already aware of the issue, especially given the non-visible nature of whitespace. Is there a way for this to fail gracefully? Either by a conversion prompt or a tweak to how things are handled? |
I must point out that this has confused me, as well. I agree with throwing compile errors when the programmer themself makes a mistake. However, I do think that this particular issue is less about the programmer and more about compatibility with software made by third parties. And even though most proper text editors have settings for choosing between @Hadron67 mentioned the idea of simply converting the line endings of string literals to However, if the compiler really must reject |
I suggest we re-open this issue. One more data point: https://lists.sr.ht/~motiejus/bazel-zig-cc/%3C167179347159.25324.12223141818448163553-0%40git.sr.ht%3E#%3Cee9821ec-6b7c-4d62-a1f2-0b54cc2ef728@hahn.graphics%3E Extract from @FabianHahn email: Zig further fails to compile launcher.zig with the following error:
The reason for this is that Git on Windows inserts carriage return |
That should be covered by #11414 |
Hi,
the following code fails to compile only on Windows:
I get this error:
I'm testing with
zig-windows-x86_64-0.9.0-dev.321+15a030ef3.zip
.Weird thing is it works fine on Linux and FreeBSD.
The text was updated successfully, but these errors were encountered: