{"record":{"id":"423df97d5b953bca","repo":"apple/pkl","slug":"notamoduletype","errorCode":"notAModuleType","errorMessage":"notAModuleType","messagePattern":"notAModuleType","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/type/UnresolvedTypeNode.java","lineNumber":218,"sourceCode":"            case \"UInt16\":\n              return new UIntTypeAliasTypeNode(alias, 0x000000000000FFFFL);\n            case \"Int32\":\n              return new Int32TypeAliasTypeNode();\n            case \"UInt32\":\n              return new UIntTypeAliasTypeNode(alias, 0x00000000FFFFFFFFL);\n            case \"UInt\":\n              return new UIntTypeAliasTypeNode(alias, 0x7FFFFFFFFFFFFFFFL);\n          }\n        }\n\n        return new TypeAliasTypeNode(sourceSection, alias, new TypeNode[0]);\n      }\n\n      var module = (VmTyped) type;\n      assert module.isModuleObject();\n      var clazz = module.getVmClass();\n      if (!module.isPrototype()) {\n        throw exceptionBuilder().evalError(\"notAModuleType\", clazz.getModuleName()).build();\n      }\n      return TypeNode.forClass(sourceSection, module.getVmClass());\n    }\n  }\n\n  public static final class Parameterized extends UnresolvedTypeNode {\n    private final VmLanguage language;\n    @Child private ExpressionNode resolveTypeNode;\n    @Children private final UnresolvedTypeNode[] typeArgumentNodes;\n\n    public Parameterized(\n        SourceSection sourceSection,\n        VmLanguage language,\n        ExpressionNode resolveTypeNode,\n        UnresolvedTypeNode[] typeArgumentNodes) {\n      super(sourceSection);\n      this.language = language;\n      this.resolveTypeNode = resolveTypeNode;","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/type/UnresolvedTypeNode.java#L200-L236","documentation":"Raised by `UnresolvedTypeNode.Module#execute`: a type annotation references a module (an object known to be a module), but that module object is not a prototype, so it cannot be used as a type. The error message `notAModuleType` includes the module name. Pkl requires type positions to reference module prototypes (the module itself), not instances/amendments of it.","triggerScenarios":"Writing a type annotation that resolves to a non-prototype module object, e.g. `x: someModule` where `someModule` was obtained by amending or instantiating rather than importing, or using `import()` result stored in a variable that got amended.","commonSituations":"Amending a module in a variable and then using the variable in type position; `import(\"...\")` assigned and mutated before use as a type; typos that resolve to a submodule instance instead of the module class.","solutions":["Use the plain module import in type position: `import \"myModule.pkl\"` then `x: myModule`.","Do not amend or instantiate the module object that you reference as a type; keep a separate import for type use.","If dynamic `import()` is needed, ensure the resolved value is the untouched module prototype.","Check the module name in the error message and verify the referenced identifier is the module itself."],"exampleFix":"// before\nimport \"config.pkl\"\nmod = (config) { x = 1 }\ny: mod = ...   // mod is amended, not a prototype\n// after\nimport \"config.pkl\"\ny: config = ...","handlingStrategy":"type-guard","validationCode":"function expectModulePrototype(mod) {\n  if (!mod || mod.__amended) throw new Error(\"type annotations must reference the module prototype, not an amendment\");\n}","typeGuard":"function isModulePrototype(v) { return v != null && typeof v === \"object\" && v.__isModule === true && !v.__amended; }","tryCatchPattern":"try {\n  useAsType(mod);\n} catch (e) {\n  // re-import the module prototype and retry\n}","preventionTips":["Use plain `import` statements for values used in type position.","Never amend a module object you also reference as a type.","Keep separate identifiers for module-as-type vs module-as-value."],"tags":["pkl","module","type-annotation","not-a-module-type"],"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-17T15:17:12.973Z"}