{"record":{"id":"a2a035b5160f17a3","repo":"apple/pkl","slug":"cannotfindsimpletype","errorCode":"cannotFindSimpleType","errorMessage":"cannotFindSimpleType (typeName, enclosingModuleName)","messagePattern":"cannotFindSimpleType \\(typeName, enclosingModuleName\\)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/type/ResolveSimpleDeclaredTypeNode.java","lineNumber":67,"sourceCode":"    var result = getType(enclosingModule, localTypeName, sourceSection);\n    if (result != null) return result;\n\n    // search module hierarchy\n    var currModule = enclosingModule;\n    do {\n      result = getType(currModule, typeName, sourceSection);\n      if (result != null) return result;\n\n      // search base module (after enclosing module, before parent modules)\n      if (!isBaseModule && currModule == enclosingModule) {\n        result = getType(BaseModule.getModule(), typeName, sourceSection);\n        if (result != null) return result;\n      }\n\n      currModule = currModule.getParent();\n    } while (currModule != null);\n\n    throw exceptionBuilder()\n        .evalError(\n            \"cannotFindSimpleType\", typeName, enclosingModule.getModuleInfo().getModuleName())\n        .build();\n  }\n}\n","sourceCodeStart":49,"sourceCodeEnd":73,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/type/ResolveSimpleDeclaredTypeNode.java#L49-L73","documentation":"`cannotFindSimpleType` is thrown by ResolveSimpleDeclaredTypeNode.executeGeneric when a simple (unqualified) type name cannot be resolved in the enclosing module or any of its parent modules. The message includes the type name and the enclosing module's name to aid locating the miss.","triggerScenarios":"Using `Foo` in a type position where no class/typealias named `Foo` exists in the current module or its ancestors; missing import for a base module type; typo in the type name.","commonSituations":"Forgetting to import a module whose types are used unqualified via glob import removal; typos like `Strng`; renaming a class without updating annotations.","solutions":["Add the required import for the module declaring the type","Correct the type name spelling","Verify the type exists in the enclosing module hierarchy or move/rename accordingly"],"exampleFix":"// before\nname: Strng\n// after\nname: String","handlingStrategy":"validation","validationCode":"// check unqualified type names are declared or imported\nif (!/(class|typealias|module)\\s+Foo\\b|^import\\b/m.test(source)) console.error(\"type Foo not found\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Import modules whose types you reference unqualified","Use editor tooling/autocomplete to avoid typos"],"tags":["pkl","type-resolution"],"backgroundTag":"resource-not-found","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"}