{"record":{"id":"5c5c6eec5ec19629","repo":"apple/pkl","slug":"invalidlinecontinuationescapesequence-5c5c6e","errorCode":"invalidLineContinuationEscapeSequence","errorMessage":"Invalid line continuation escape sequence.\n\nLine continuations are only allowed in multi-line strings.","messagePattern":"Invalid line continuation escape sequence\\.\n\nLine continuations are only allowed in multi-line strings\\.","errorType":"exception","errorClass":"ParserError","httpStatus":null,"severity":"error","filePath":"pkl-parser/src/main/java/org/pkl/parser/ParserImpl.java","lineNumber":1135,"sourceCode":"        case STRING_ESCAPE_QUOTE -> {\n          end = next().span;\n          builder.append('\"');\n        }\n        case STRING_ESCAPE_BACKSLASH -> {\n          end = next().span;\n          builder.append('\\\\');\n        }\n        case STRING_ESCAPE_RETURN -> {\n          end = next().span;\n          builder.append('\\r');\n        }\n        case STRING_ESCAPE_UNICODE -> {\n          var tk = next();\n          end = tk.span;\n          builder.append(parseUnicodeEscape(tk));\n        }\n        case STRING_ESCAPE_CONTINUATION ->\n            throw parserError(\"invalidLineContinuationEscapeSequence\");\n        case INTERPOLATION_START -> {\n          var istart = next().span;\n          if (!builder.isEmpty()) {\n            parts.add(new StringChars(builder.toString(), startSpan.endWith(end)));\n            builder = new StringBuilder();\n          }\n          var exp = parseExpr(\")\");\n          end = expect(Token.RPAREN, \"unexpectedToken\", \")\").span;\n          parts.add(new StringPart.StringInterpolation(exp, istart.endWith(end)));\n          startSpan = spanLookahead;\n        }\n        case EOF -> {\n          var delimiter = new StringBuilder(start.text(lexer)).reverse().toString();\n          throw parserError(\"missingDelimiter\", delimiter);\n        }\n      }\n    }\n    if (!builder.isEmpty()) {","sourceCodeStart":1117,"sourceCodeEnd":1153,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-parser/src/main/java/org/pkl/parser/ParserImpl.java#L1117-L1153","documentation":"Pkl string literals do not support the `\\` line-continuation escape sequence inside single-line strings; it is only meaningful in multi-line (`\"\"\"`) strings, where a backslash at end of line suppresses the newline. The parser throws this error when it encounters STRING_ESCAPE_CONTINUATION while parsing a single-line string. It is a hard syntax error at parse time.","triggerScenarios":"Parsing a Pkl file that contains a single-line string ending in a backslash (e.g. `\"foo \\` followed by a newline), e.g. via pkl CLI eval, codegen, or `ParserImpl` direct use.","commonSituations":"Copy-pasting shell/JS-style line continuations into Pkl config files; hand-splitting long string values across lines in property values or module documentation.","solutions":["Remove the trailing backslash from the single-line string","Use a multi-line string (triple-quoted `\"\"\"...\"\"\"`) if the continuation was intended","Join the text onto one line, or use string concatenation/interpolation instead"],"exampleFix":"// before\ngreeting = \"hello \\\n  world\"\n// after\ngreeting = \"\"\"\nhello \\\n  world\n\"\"\"","handlingStrategy":"validation","validationCode":"function hasStrayLineContinuation(src) {\n  return /[^\\\\](\\\\\\\\)*\\\\$/.test(src.split('\\n').filter(l => !l.trim().startsWith('\"\"\"')).join('\\n'));\n}","typeGuard":null,"tryCatchPattern":"try { pklEval(source) } catch (e) {\n  if (String(e.message).includes('Invalid line continuation escape sequence')) {\n    throw new Error('Use triple-quoted \"\"\" strings for line continuations in Pkl');\n  }\n  throw e;\n}","preventionTips":["Never end a single-line Pkl string with a backslash","Use triple-quoted multi-line strings for wrapped text","Lint Pkl sources in CI before evaluation"],"tags":["pkl","parser","string-literal"],"backgroundTag":"parser-syntax-error","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"}