{"record":{"id":"5c0384f50b0de726","repo":"apple/pkl","slug":"unexpected-character-0-did-you-mean-1-5c0384","errorCode":null,"errorMessage":"Unexpected character `{0}`. Did you mean `{1}`, `{2}` or `{3}`?","messagePattern":"Unexpected character `(.+?)`\\. Did you mean `(.+?)`, `(.+?)` or `(.+?)`\\?","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkl-parser/src/main/java/org/pkl/parser/Lexer.java","lineNumber":237,"sourceCode":"          nextChar();\n          yield Token.INT_DIV;\n        } else {\n          throw unexpectedChar(ch, \"~/\");\n        }\n      }\n      case '.' -> {\n        if (lookahead == '.') {\n          nextChar();\n          if (lookahead == '.') {\n            nextChar();\n            if (lookahead == '?') {\n              nextChar();\n              yield Token.QSPREAD;\n            } else {\n              yield Token.SPREAD;\n            }\n          } else {\n            throw unexpectedChar(\"..\", \".\", \"...\", \"...?\");\n          }\n        } else if (lookahead >= '0' && lookahead <= '9') {\n          yield lexNumber(ch);\n        } else {\n          yield Token.DOT;\n        }\n      }\n      case '`' -> {\n        lexQuotedIdentifier();\n        yield Token.IDENTIFIER;\n      }\n      case '/' -> lexSlash();\n      case '\"' -> lexStringStart(0);\n      case '#' -> {\n        if (lookahead == '!') {\n          yield lexShebang();\n        } else {\n          yield lexStringStartPounds();","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-parser/src/main/java/org/pkl/parser/Lexer.java#L219-L255","documentation":"The lexer sees a `.` starting a dot-sequence that does not form a valid token. Valid forms are `.` (member access), `..` (range), `...` (spread), `...?` (null-safe spread), and `..` followed by digits (number like `1.5` handled elsewhere). Anything else, e.g. `.?` or `....`, triggers unexpectedChar with the four valid suggestions.","triggerScenarios":"Writing malformed dot sequences such as `.?`, `. …` mixing characters, `..*`, or an accidental extra dot in spread/range syntax — e.g. `....` or `..?`.","commonSituations":"Typos in null-safe spread (`...?` written as `..?`); optional chaining habits from TypeScript (`?.`) typed into Pkl; hand-written range expressions missing a bound.","solutions":["If optional access was intended, note Pkl uses `?.` on method/reference syntax differently — check docs and use the supported form.","Fix the spread syntax: use `...` or `...?` exactly.","Use a single `.` for member access or `..` for ranges.","Remove the extra/stray dot characters."],"exampleFix":"// before (TypeScript habit)\nfoo?.bar\n\n// after\nfoo?.bar // only if supported in your Pkl version; otherwise:\nfoo.bar","handlingStrategy":"validation","validationCode":"function assertValidDotSequence(src) {\n  const bad = src.match(/\\.{4,}|\\.\\?|\\.\\.\\?\\?|\\.\\./g);\n  // allow '..' ranges but flag '.?' and 4+ dots\n  const illegal = src.match(/\\.\\?|\\.{4,}/);\n  if (illegal) throw new Error(`Invalid dot sequence '${illegal[0]}' at index ${illegal.index}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Memorize the valid forms: `.`, `..`, `...`, `...?`.","Do not assume TypeScript `?.` chaining exists in Pkl; verify against current docs.","Lint generated code for accidental double-doubled dots."],"tags":["lexer","syntax-error","unexpected-character","spread"],"backgroundTag":"invalid-characters","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"}