Skip to content

Point invalid string escape diagnostics at the escape instead of the following token #519

Closed

Description

@LunaStev

Reproduced on canonical master 0c67f4c:

fun main() { "\q"; }

wavec --error-format=json check input.wave reports E1004 with start:16,end:16,column:17, after the invalid escape and at the closing quote. The actual \q is bytes 14..16. Human output points at the quote as well.

Lexer::string in front/lexer/src/literals.rs calls make_error_here after consuming escape characters. Unknown escapes, invalid hex escapes and incomplete escapes therefore use the post-consumption cursor rather than the offending escape's start.

Capture the backslash location and use it when constructing string-escape failures. Keep the existing accepted syntax and error codes. Assert exact UTF-8 byte slices, line/column, and human/JSON parity for unknown, malformed hex and truncated escapes, including non-ASCII text before the escape and CRLF.

#390 tracks broader string/character lexer diagnostic tests; this issue records the concrete string-escape location defect.

Activity

  1. added
    help wanted
    on Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions