{"record":{"id":"882ed4119a942318","repo":"apple/pkl","slug":"outerisnotconst","errorCode":"outerIsNotConst","errorMessage":"outerIsNotConst","messagePattern":"outerIsNotConst","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java","lineNumber":625,"sourceCode":"            .withSourceSection(createSourceSection(expr))\n            .evalError(\"thisIsNotConst\")\n            .build();\n      }\n    }\n    return VmUtils.createThisNode(\n        createSourceSection(expr), symbolTable.getCurrentScope().isCustomThisScope());\n  }\n\n  // TODO: `outer.` should probably have semantics similar to `super.`,\n  // rather than just performing a lookup in the immediately enclosing object\n  // also, consider interpreting `x = ... x ...` as `x = ... outer.x ...`\n  @Override\n  public OuterNode visitOuterExpr(OuterExpr expr) {\n    if (!(expr.parent() instanceof QualifiedAccessExpr)) {\n      var constLevel = symbolTable.getCurrentScope().getConstLevel();\n      var outerScope = getParentLexicalScope();\n      if (outerScope != null && constLevel.bigger(outerScope.getConstLevel())) {\n        throw exceptionBuilder()\n            .evalError(\"outerIsNotConst\")\n            .withSourceSection(createSourceSection(expr))\n            .build();\n      }\n    }\n    return new OuterNode(createSourceSection(expr));\n  }\n\n  @Override\n  public ExpressionNode visitModuleExpr(ModuleExpr expr) {\n    var currentScope = symbolTable.getCurrentScope();\n    // cannot use unqualified `module` in a const context\n    if (currentScope.getConstLevel().isConst() && !(expr.parent() instanceof QualifiedAccessExpr)) {\n      var scope = currentScope;\n      while (scope != null\n          && !(scope instanceof AnnotationScope)\n          && !(scope instanceof ClassScope)) {\n        scope = scope.getParent();","sourceCodeStart":607,"sourceCodeEnd":643,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java#L607-L643","documentation":"AstBuilder.visitOuterExpr throws 'outerIsNotConst' when unqualified `outer` appears in a const context (annotation arguments and similar), since `outer` resolves dynamically through the enclosing object chain and cannot be evaluated as a constant. The input at fault is a bare `outer` expression in a const position.","triggerScenarios":"Thrown at pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java:625 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Qualify the outer access (e.g. `outer.foo`) so the reference is static.","Avoid `outer` inside annotation arguments; pass the needed value explicitly."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}