{"record":{"id":"46dcd0f0b746d767","repo":"apple/pkl","slug":"invalidlinecontinuationescapesequence","errorCode":"invalidLineContinuationEscapeSequence","errorMessage":"Invalid line continuation escape sequence.","messagePattern":"Invalid line continuation escape sequence\\.","errorType":"exception","errorClass":"GenericParserError","httpStatus":null,"severity":"error","filePath":"pkl-parser/src/main/java/org/pkl/parser/GenericParserImpl.java","lineNumber":982,"sourceCode":"    var start = next();\n    children.add(makeTerminal(start)); // string start\n    while (lookahead != Token.STRING_END) {\n      switch (lookahead) {\n        case STRING_PART -> {\n          var tk = next();\n          if (!tk.text(lexer).isEmpty()) {\n            children.add(make(NodeType.STRING_CHARS, tk.span));\n          }\n        }\n        case STRING_ESCAPE_NEWLINE,\n            STRING_ESCAPE_TAB,\n            STRING_ESCAPE_QUOTE,\n            STRING_ESCAPE_BACKSLASH,\n            STRING_ESCAPE_RETURN,\n            STRING_ESCAPE_UNICODE ->\n            children.add(make(NodeType.STRING_ESCAPE, next().span));\n        case STRING_ESCAPE_CONTINUATION ->\n            throw parserError(\"invalidLineContinuationEscapeSequence\");\n        case INTERPOLATION_START -> {\n          children.add(makeTerminal(next()));\n          ff(children);\n          children.add(parseExpr(\")\"));\n          ff(children);\n          expect(Token.RPAREN, children, \"unexpectedToken\", \")\");\n        }\n        case EOF -> {\n          var delimiter = new StringBuilder(start.text(lexer)).reverse().toString();\n          throw parserError(\"missingDelimiter\", delimiter);\n        }\n      }\n    }\n    children.add(makeTerminal(next())); // string end\n    return new Node(NodeType.SINGLE_LINE_STRING_LITERAL_EXPR, children);\n  }\n\n  private Node parseMultiLineStringLiteralExpr() {","sourceCodeStart":964,"sourceCodeEnd":1000,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-parser/src/main/java/org/pkl/parser/GenericParserImpl.java#L964-L1000","documentation":"A `\\` line-continuation escape was found inside a string literal in an invalid position (e.g. not at end-of-line), so the parser rejects it. Pkl only allows the continuation escape immediately before a line break.","triggerScenarios":"The lexer produced a STRING_ESCAPE_CONTINUATION token where it is not a valid line continuation — e.g. `\\` followed by characters on the same line inside a string.","commonSituations":"Escaping a trailing backslash unintentionally (Windows paths like \"C:\\temp\" pasted into Pkl strings); a regex or path written without doubling backslashes; stray `\\` before a non-newline character.","solutions":["Remove the stray `\\` if no escape was intended","Place the `\\` immediately before the newline to continue the string, with no trailing spaces","Escape backslashes properly: write `\"C:\\\\temp\"` for a literal backslash"],"exampleFix":"// before\nval p = \"C:\\temp\"\n// after\nval p = \"C:\\\\temp\"\n// or a real continuation:\nval s = \"first \\\nsecond\"","handlingStrategy":"validation","validationCode":"/\\\\[^\\n]/.test(src) // a backslash followed by something other than newline inside string content — likely an invalid continuation or needs doubling","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Double backslashes in Windows paths and regexes inside Pkl strings","Only use `\\` at the very end of a line for continuations","Check pasted content for stray trailing backslashes"],"tags":["parser","pkl","string-literal","escape-sequence","syntax-error"],"backgroundTag":"invalid-escape-sequence","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}