Skip to content

Invalid escape sequences in strings and characters are not properly reported #29

@PeterGriffinSr

Description

@PeterGriffinSr

Describe the bug
When using invalid escape sequences inside string or character literals, Zura Lang either fails to report an error properly or crashes.

To reproduce
Steps to reproduce the behavior:

  1. Create two separate files strings.zu and chars.zu with the following contents:
const main := fn () int! {
    have x: str  = "Hello\xZ";
    return 0;
};

const main := fn () int! {
    have x: char  = '\q';
    return 0;
};
  1. Run the command:
./debug/zura build zura_files/main.zu
  1. Observe the behavior:
  • No error is reported for the invalid escape sequence in the string literal "Hello\xZ".
  • The invalid escape in the character literal '\q' produces an error message, but then the compiler crashes with a segmentation fault.

Expected behavior

  • The compiler should report invalid escape sequence errors for both string and character literals.
  • The compiler should not crash when encountering invalid characters.
  • Error messages should point to the exact location in the source file. Example:
chars.zu:2:23: Lexer error: Invalid escape sequence in character literal '\q'
strings.zu:2:18: Lexer error: Invalid escape sequence in string literal "Hello\xZ"

screenshots

Image Image

Additional context

  • Zura Lang version: v0.1.46
  • This issue affects any invalid escape sequences (\x with non-hex digits, unsupported letters, etc.) in both strings and character literals.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions