Skip to content
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

CR-LF Line Endings Break Multi-Line Strings #11414

Closed
stellahymmne opened this issue Apr 11, 2022 · 4 comments · Fixed by #12661
Closed

CR-LF Line Endings Break Multi-Line Strings #11414

stellahymmne opened this issue Apr 11, 2022 · 4 comments · Fixed by #12661
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. zig fmt
Milestone

Comments

@stellahymmne
Copy link

stellahymmne commented Apr 11, 2022

Zig Version

0.9.0

Steps to Reproduce

test "Multi-Line Strings" {
    const str = 
    \\a b
    \\  c
    ;
}

This code will compile when lines end with only a \n newline character, but will break if Windows-style \r\n line endings are used.

Expected Behavior

The code compiles successfully.

Actual Behavior

src\test.zig:10:10: error: expected ';', found invalid bytes
    \\a b
         ^
src\test.zig:11:6: note: invalid byte: '\\'
    \\  c
     ^
@stellahymmne stellahymmne added the bug Observed behavior contradicts documented or intended behavior label Apr 11, 2022
@ominitay
Copy link
Contributor

Won't be fixed. Wait for the self-hosted compiler, in which this works as intended. In the meantime, fix your editor and git configs, and run zig fmt to quickly fix this.

@nektro
Copy link
Contributor

nektro commented Apr 11, 2022

intentional behavior, not a bug

@Vexu
Copy link
Member

Vexu commented Apr 28, 2022

Current plan is for zig fmt to fix this ziglang/zig-spec#38

Also worth noting that the example currently crashes a debug build of zig fmt.

@moosichu
Copy link
Sponsor Contributor

moosichu commented Aug 27, 2022

Looking at fixing this now as a heads-up. It's worth highlighting that this now crashes the compiler as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. zig fmt
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants