{"record":{"id":"b6a219eb509ffaae","repo":"apple/pkl","slug":"errormessage-this-will-be-an-error-in-a-future","errorCode":null,"errorMessage":"${errorMessage} This will be an error in a future release.","messagePattern":"(.+?) This will be an error in a future release\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java","lineNumber":428,"sourceCode":"          var parentScope = scope.getParent();\n          assert parentScope != null;\n          // if the parent also has \"ALL\", we haven't found the originating const property/method\n          // yet.\n          if (parentScope.getConstLevel() == ConstLevel.ALL) {\n            continue;\n          }\n          var message =\n              scope.isPropertyScope() ? \"invalidModuleTypeInProperty\" : \"invalidModuleTypeInMethod\";\n          errorMessage = ErrorMessages.create(message, scope.getQualifiedName());\n          break;\n        }\n      }\n    }\n    assert errorMessage != null;\n    // TODO: when making this an error, update comment on moduleClass in ReferenceTypeNode.eval\n    VmContext.get(null)\n        .getLogger()\n        .warn(\n            errorMessage + \" This will be an error in a future release.\",\n            VmUtils.createStackFrame(sourceSection, null));\n  }\n\n  @Override\n  public UnresolvedTypeNode visitThisType(ThisType type) {\n    var sourceSection = createSourceSection(type);\n    // need to pass explicit class name for property and method arg/return type annotations.\n    // this is because type annotations on class properties/methods are initialized when the\n    // ClassNode\n    // is executed, and the frame's receiver is the enclosing module rather than the class.\n    // do not need: when in any object or at the module level (where `this` is the receiver's class)\n    org.pkl.core.runtime.Identifier className = null;\n    for (var scope = symbolTable.getCurrentScope(); scope != null; scope = scope.getParent()) {\n      if (scope.isObjectScope() || scope.isCustomThisScope()) {\n        break;\n      }\n      if (scope instanceof ClassScope foundClassScope) {","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java#L410-L446","documentation":"AstBuilder.checkModuleType detects Pkl source that declares a module type in a way that is currently tolerated but will become an error. Instead of throwing, it logs a deprecation warning with the specific errorMessage and a stack frame pointing at the offending source section.","triggerScenarios":"Compiling/evaluating a Pkl module whose module type usage (via visitModuleType) triggers the deprecated pattern — e.g. referencing a class as a module type in a way future releases will forbid.","commonSituations":"Older Pkl codebases evaluated on newer pkl-core, code that relied on lenient module-type references, migration audits before upgrading Pkl.","solutions":["Read the logged errorMessage to identify the exact module-type usage.","Update the module to declare/consume the module type per current Pkl conventions.","Fix moduleClass references in modules per the note in ReferenceTypeNode.eval.","Test module evaluation on the newest pkl-core to catch the upcoming hard error."],"exampleFix":"// before (Pkl)\ntypealias MyModule = ModuleTypeUsedIncorrectly\n// after\nclass MyModule extends BaseModule {} // use current module declaration style","handlingStrategy":"validation","validationCode":"// CI check: run pkl evaluation with warnings-as-errors to surface future-breaking module type usage\npkl eval --no-cache module.pkl 2>&1 | tee eval.log\ngrep -q \"This will be an error in a future release\" eval.log && exit 1 || true","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat pkl-core deprecation warnings as CI failures","Update module declarations to current conventions proactively","Review ReferenceTypeNode/moduleClass guidance when migrating","Re-run module tests on each pkl upgrade"],"tags":["deprecation","pkl","ast","compiler"],"backgroundTag":"deprecated-api-usage","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"}