{"record":{"id":"2c38d832505d51c9","repo":"apple/pkl","slug":"notamoduleimport","errorCode":"notAModuleImport","errorMessage":"notAModuleImport","messagePattern":"notAModuleImport","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/type/ResolveDeclaredTypeNode.java","lineNumber":59,"sourceCode":"\n    assert curr.isModuleObject();\n    return (VmTyped) curr;\n  }\n\n  protected VmTyped getImport(\n      VmTyped module, Identifier importName, SourceSection importNameSection) {\n    assert importName.isLocalProp();\n\n    var member = module.getMember(importName);\n    if (member == null) {\n      throw exceptionBuilder()\n          .evalError(\"cannotFindModuleImport\", importName)\n          .withSourceSection(importNameSection)\n          .build();\n    }\n\n    if (!member.isImport()) {\n      throw exceptionBuilder()\n          .evalError(\"notAModuleImport\", importName)\n          .withSourceSection(importNameSection)\n          .build();\n    }\n\n    if (member.isGlob()) {\n      throw exceptionBuilder()\n          .evalError(\"notAType\", importName)\n          .withSourceSection(importNameSection)\n          .build();\n    }\n\n    assert member.getConstantValue() == null;\n    var result = module.getCachedValue(importName);\n    if (result == null) {\n      result = callNode.call(member.getCallTarget(), module, module, importName);\n      module.setCachedValue(importName, result);\n    }","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/type/ResolveDeclaredTypeNode.java#L41-L77","documentation":"`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.","triggerScenarios":"Writing `someProp.Type` in a type position where `someProp` is a regular property (not an `import \"...\" as someProp` binding).","commonSituations":"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.","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"],"exampleFix":"// before\nx: myProp.Config\n// after\nimport \"config.pkl\" as conf\nx: conf.Config","handlingStrategy":"validation","validationCode":"// qualified type prefix must be an import, not a property\nconst isImport = /^import\\b/.test(lineOf(prefix));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use import aliases (not local properties) in type positions","Avoid shadowing import names with properties"],"tags":["pkl","import","type-resolution"],"backgroundTag":"invalid-argument-value","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"}