Compiler-explorer: Zig does not compile because of line endings

Created on 15 Jan 2019  路  4Comments  路  Source: compiler-explorer/compiler-explorer

Currently, I'm not able to compile any Zig code containing line breaks (just try with the default square function), getting this compiler error: <source>:2:33: error: invalid carriage return, only '\n' line endings are supported.

see also https://ziglang.org/documentation/master/#Source-Encoding

bug lang-zig

Most helpful comment

Ey! Sorry this took so long. I have forced a LF EOL in the editor which seems to fix the problem and not cause other languages to fail, so the fix should be pushed with the next site update :)
I missreferenced the issue in the commit message, but e326384 closes this

All 4 comments

CC @tiehuis - any ideas?

On Windows it appears Monaco gives back lines with carriage returns when asking for text from the buffer by default since we don't explicitly specify what we want.

Adding a request explicitly for newline only data from the editor should fix this, presumably at this point here. See api documentation for getValue.

Changing like this would be shared across all languages however, would this behavior be valid? Is there any reason to keep the status quo for any languages?

From @RabsRincon (who is offline but replied in slack):

this.editor.getModel().setEOL(monaco.editor.EndOfLineSequence.LF);

plus a bit of logic should do the trick on the editor

Ey! Sorry this took so long. I have forced a LF EOL in the editor which seems to fix the problem and not cause other languages to fail, so the fix should be pushed with the next site update :)
I missreferenced the issue in the commit message, but e326384 closes this

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adiba picture adiba  路  4Comments

obfuscated picture obfuscated  路  5Comments

mathbunnyru picture mathbunnyru  路  4Comments

pps83 picture pps83  路  5Comments

VivekChugh picture VivekChugh  路  3Comments