Skip to content

Invalid string literal escape sequences should err #1593

@mhasel

Description

@mhasel

Invalid escape sequences are interpreted as literal strings instead of producing a compile-time error:

FUNCTION main : DINT
VAR
    incomplete : STRING := '$1';   // should error: incomplete hex byte
    invalid    : STRING := '$GG';  // should error: 'G' is not a hex digit or valid IEC escape
END_VAR
    printf('%s$N', incomplete);    // prints "$1"
    printf('%s$N', invalid);       // prints "$GG"
END_FUNCTION

Expected: Compile-time error for malformed escape sequences
Actual: Silently treated as literal $ + following characters

For reference, CODESYS rejects these at compile time.

Reference table for all IEC 61131-3 escapes:

Escape Meaning
$$ Dollar sign
$' Single quote
$" Double quote
$L / $l Line feed
$N / $n Newline (platform-dependent)
$R / $r Carriage return
$T / $t Tab
$P / $p Form feed
$hh Hex byte (STRING)
$hhhh Hex code unit (WSTRING)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingvalidationcandidate for syntactic or semantic validation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions