{"record":{"id":"079eb9af60d1f57f","repo":"apple/pkl","slug":"unexpectedendoffile-079eb9","errorCode":"unexpectedEndOfFile","errorMessage":"Unexpected end of file.","messagePattern":"Unexpected end of file\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkl-parser/src/main/java/org/pkl/parser/Lexer.java","lineNumber":312,"sourceCode":"        return Token.STRING_NEWLINE;\n      }\n      if (lookahead == '\\n') {\n        nextChar();\n        return Token.STRING_NEWLINE;\n      }\n      lexMultiString(scope.pounds);\n    }\n    return Token.STRING_PART;\n  }\n\n  private Token lexStringStartPounds() {\n    int pounds = 1;\n    while (lookahead == '#') {\n      nextChar();\n      pounds++;\n    }\n    if (lookahead == EOF) {\n      throw lexError(ErrorMessages.create(\"unexpectedEndOfFile\"), span());\n    }\n    if (lookahead != '\"') {\n      throw unexpectedChar(lookahead, \"\\\"\");\n    }\n    nextChar();\n    return lexStringStart(pounds);\n  }\n\n  private Token lexStringStart(int pounds) {\n    var quotes = 1;\n    if (lookahead == '\"') {\n      nextChar();\n      if (lookahead == '\"') {\n        nextChar();\n        quotes = 3;\n      } else {\n        backup();\n      }","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-parser/src/main/java/org/pkl/parser/Lexer.java#L294-L330","documentation":"While lexing the start of a custom-delimiter string (a `#` opening a `#\"...\"#` style string), lexStringStartPounds() reaches EOF before finding the opening quote. Since the string never begins, the lexer throws unexpectedEndOfFile. This guards `#...#` multi-pound custom string syntax against truncated input.","triggerScenarios":"Source contains `#`, `##`, etc. (starting a custom string) but the file ends before a `\"` follows — e.g. a `#\"\"\"...\"\"\"#` string whose content was cut off, or a lone `#` at end of file.","commonSituations":"Truncated file from failed save/download; heredoc or template script that dropped the rest of the string; regex-like `#` comments written assuming `#` starts a comment (Pkl uses `///` or `//` for comments, not `#`).","solutions":["Complete the custom string: follow the `#`s with `\"` and close with `\"` plus the same number of `#`s, e.g. `#\"text\"#`.","If a comment was intended, use `//` or `///` instead of `#`.","Check the file for truncation and restore the missing content."],"exampleFix":"// before\npattern = #\\d+#\n\n// after\npattern = #\"\\d+\"#","handlingStrategy":"validation","validationCode":"function validateCustomStrings(src) {\n  // every run of #'s must be followed (eventually) by a quote before EOF\n  const re = /#+(?![\"\\/#])/g;\n  let m;\n  while ((m = re.exec(src))) {\n    throw new Error(`'#' at index ${m.index} does not start a comment or custom string`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Close custom strings with matching pound count: `#\"...\"#`, `##\"...\"##`.","Use `//` or `///` for comments — `#` is not a Pkl comment marker.","Verify generated files end with the expected closing delimiters before publishing."],"tags":["lexer","syntax-error","eof","string"],"backgroundTag":"unexpected-end-of-input","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}