apple/pkl · error
cannotFindSimpleType
cannotFindSimpleType
Error message
cannotFindSimpleType (typeName, enclosingModuleName)
What it means
`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.
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
Example fix
// before name: Strng // after name: String
Defensive patterns
Strategy: validation
Validate before calling
// check unqualified type names are declared or imported
if (!/(class|typealias|module)\s+Foo\b|^import\b/m.test(source)) console.error("type Foo not found"); Prevention
- Import modules whose types you reference unqualified
- Use editor tooling/autocomplete to avoid typos
When it happens
Trigger: 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.
Common situations: Forgetting to import a module whose types are used unqualified via glob import removal; typos like `Strng`; renaming a class without updating annotations.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- cannotFindModuleImport
- cannotFindQualifiedType
- cannotResolveTypeForProtobuf
- invalidSupertype
- notAModuleImport
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/a2a035b5160f17a3.
Report an issue: GitHub.
Appendix: source
Thrown at pkl-core/src/main/java/org/pkl/core/ast/type/ResolveSimpleDeclaredTypeNode.java:67
var result = getType(enclosingModule, localTypeName, sourceSection);
if (result != null) return result;
// search module hierarchy
var currModule = enclosingModule;
do {
result = getType(currModule, typeName, sourceSection);
if (result != null) return result;
// search base module (after enclosing module, before parent modules)
if (!isBaseModule && currModule == enclosingModule) {
result = getType(BaseModule.getModule(), typeName, sourceSection);
if (result != null) return result;
}
currModule = currModule.getParent();
} while (currModule != null);
throw exceptionBuilder()
.evalError(
"cannotFindSimpleType", typeName, enclosingModule.getModuleInfo().getModuleName())
.build();
}
}
View on GitHub (pinned to f3efcbfc9b)