apple/pkl · error
notAModuleImport
notAModuleImport
Error message
notAModuleImport
What it means
`notAModuleImport` is thrown by ResolveDeclaredTypeNode.getImport when the identifier in a qualified type resolves to a module member that exists but is not an import. Qualified types must be anchored to an imported module, not to an arbitrary property.
Source
Thrown at pkl-core/src/main/java/org/pkl/core/ast/type/ResolveDeclaredTypeNode.java:59
assert curr.isModuleObject();
return (VmTyped) curr;
}
protected VmTyped getImport(
VmTyped module, Identifier importName, SourceSection importNameSection) {
assert importName.isLocalProp();
var member = module.getMember(importName);
if (member == null) {
throw exceptionBuilder()
.evalError("cannotFindModuleImport", importName)
.withSourceSection(importNameSection)
.build();
}
if (!member.isImport()) {
throw exceptionBuilder()
.evalError("notAModuleImport", importName)
.withSourceSection(importNameSection)
.build();
}
if (member.isGlob()) {
throw exceptionBuilder()
.evalError("notAType", importName)
.withSourceSection(importNameSection)
.build();
}
assert member.getConstantValue() == null;
var result = module.getCachedValue(importName);
if (result == null) {
result = callNode.call(member.getCallTarget(), module, module, importName);
module.setCachedValue(importName, result);
}View on GitHub (pinned to f3efcbfc9b)
Solutions
- Import the module explicitly (`import "path.pkl" as name`) and use `name.Type`
- Rename the shadowing property so the import name is not obscured
- Use the module's import alias rather than a local property in type positions
Example fix
// before x: myProp.Config // after import "config.pkl" as conf x: conf.Config
Defensive patterns
Strategy: validation
Validate before calling
// qualified type prefix must be an import, not a property const isImport = /^import\b/.test(lineOf(prefix));
Prevention
- Use import aliases (not local properties) in type positions
- Avoid shadowing import names with properties
When it happens
Trigger: Writing `someProp.Type` in a type position where `someProp` is a regular property (not an `import "..." as someProp` binding).
Common situations: Confusing a property holding a module value with an actual import; shadowing an import name with a property; referencing a local object instead of a module in a qualified type.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/2c38d832505d51c9.
Report an issue: GitHub.