{"record":{"id":"205b4a763afc5498","repo":"apple/pkl","slug":"invalidtypename","errorCode":"invalidTypeName","errorMessage":"invalidTypeName","messagePattern":"invalidTypeName","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java","lineNumber":2404,"sourceCode":"        yield new ResolveSimpleDeclaredTypeNode(\n            sourceSection,\n            org.pkl.core.runtime.Identifier.get(identifier.getValue()),\n            isBaseModule,\n            getModuleNode);\n      }\n      case 2 -> {\n        var identifier1 = identifiers.get(0);\n        var identifier2 = identifiers.get(1);\n        yield new ResolveQualifiedDeclaredTypeNode(\n            createSourceSection(ctx),\n            createSourceSection(identifier1),\n            createSourceSection(identifier2),\n            org.pkl.core.runtime.Identifier.localProperty(identifier1.getValue()),\n            org.pkl.core.runtime.Identifier.get(identifier2.getValue()),\n            getModuleNode);\n      }\n      default ->\n          throw exceptionBuilder()\n              .evalError(\"invalidTypeName\", ctx.text())\n              .withSourceSection(createSourceSection(ctx))\n              .build();\n    };\n  }\n\n  private ExpressionNode doVisitObjectBody(\n      List<? extends ObjectBody> bodies, ExpressionNode parentNode) {\n    for (var ctx : bodies) {\n      parentNode = doVisitObjectBody(ctx, parentNode);\n    }\n    return parentNode;\n  }\n\n  private void addObjectNamesToScope(ObjectScope scope, ObjectBody body) {\n    for (var member : body.getMembers()) {\n      if (member instanceof ObjectProperty prop) {\n        var local = hasLocalModifier(prop.getModifiers());","sourceCodeStart":2386,"sourceCodeEnd":2422,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java#L2386-L2422","documentation":"Thrown when the text of a type-reference context does not match any recognized type-name shape. visitType(GrAdditiveTypeContext etc.) switches on the grammar alternative; the `default` arm rejects anything that is not a valid type expression form (identifier, qualified name, module type, etc.).","triggerScenarios":"Using an invalid token or malformed expression where a type is expected, e.g. `x: (a | b).c`, an operator in a type position, or a malformed union/intersection with unexpected structure. The error reports `ctx.text()` of the offending region.","commonSituations":"Typos in type positions (`x: Strng` is actually a valid identifier that fails resolution, but stray punctuation like `x: String.?` hits this); editing types and leaving dangling operators; copy-paste of type syntax from other languages (e.g. TypeScript's `typeof`).","solutions":["Inspect `ctx.text()` in the message and rewrite the type using valid Pkl type syntax: `String`, `Listing<Int>`, `module`, `unknown`, unions `A|B`, conjunctions `A&B`.","Remove stray punctuation/operators from the type position.","Wrap the intended type reference in parentheses correctly if composing unions/conjunctions."],"exampleFix":"// before\nname: String.?\n// after\nname: String?","handlingStrategy":"validation","validationCode":"// allow only known type-position constructs before handing to Pkl\nconst VALID = /^[A-Za-z_][\\w.]*(\\s*[|&]\\s*[A-Za-z_][\\w.]*|<[^>]+>|\\?)*$/;\nif (!VALID.test(typeText)) throw new Error(`malformed type: ${typeText}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use documented type syntax: named types, parameterized types, `?` nullable, `|` union, `&` conjunction, `module`, `unknown`, `nothing`.","Beware other languages' syntax (typeof, keyof, generics on classes) leaking into type positions."],"tags":["pkl","type-system","syntax","compile-error"],"backgroundTag":"invalid-identifier-format","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"}