{"record":{"id":"1e26e59419dc6191","repo":"apple/pkl","slug":"missingmethodbody","errorCode":"missingMethodBody","errorMessage":"missingMethodBody","messagePattern":"missingMethodBody","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java","lineNumber":2181,"sourceCode":"              throw exceptionBuilder()\n                  .evalError(\"abstractMemberCannotHaveBody\")\n                  .withSourceSection(headerSection)\n                  .build();\n            }\n            bodyNode = visitExpr(bodyContext);\n          } else {\n            if (VmModifier.isExternal(modifiers)) {\n              bodyNode =\n                  externalMemberRegistry.getFunctionBody(\n                      scope.getQualifiedName(), headerSection, paramCount);\n              if (bodyNode instanceof LanguageAwareNode languageAwareNode) {\n                languageAwareNode.initLanguage(language);\n              }\n            } else if (VmModifier.isAbstract(modifiers)) {\n              bodyNode =\n                  new CannotInvokeAbstractFunctionNode(headerSection, scope.getQualifiedName());\n            } else {\n              throw exceptionBuilder()\n                  .evalError(\"missingMethodBody\", methodName)\n                  .withSourceSection(headerSection)\n                  .build();\n            }\n          }\n\n          return new UnresolvedMethodNode(\n              language,\n              createSourceSection(entry),\n              headerSection,\n              scope.buildFrameDescriptor(),\n              createDocSourceSection(entry.getDocComment()),\n              annotations,\n              modifiers,\n              methodName,\n              scope.getQualifiedName(),\n              paramCount,\n              typeParameters,","sourceCodeStart":2163,"sourceCodeEnd":2199,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java#L2163-L2199","documentation":"Thrown when a function member has neither a body nor the `abstract` modifier. Pkl requires every non-abstract function to implement something; a bare signature is invalid syntax for a concrete function. Abstract functions without bodies are allowed and compile to CannotInvokeAbstractFunctionNode.","triggerScenarios":"Writing `function foo(): Int` (no `= expr`, no `abstract`) inside a class or module. Fires in the else branch of the body-handling logic where modifiers are not abstract and no bodyNode was produced.","commonSituations":"Porting Java interface-style declarations into Pkl and forgetting `abstract`; deleting a function body during refactoring; incomplete code generation or templated snippets left unimplemented.","solutions":["Add a body: `function foo(): Int = 42`.","Or mark the member `abstract` if it must be implemented by subclasses.","Or remove the declaration entirely if it is unused."],"exampleFix":"// before\nfunction render(): String\n// after\nabstract function render(): String\n// or\nfunction render(): String = \"default\"","handlingStrategy":"validation","validationCode":"// every function member needs a body or the abstract modifier\nfunction validateFunctionMember(m) {\n  if (!m.isAbstract && m.body == null)\n    throw new Error(`function ${m.name} needs a body or 'abstract'`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never leave a function signature without `= expr` or `abstract` when porting interface-style code.","Grep for `^\\s*function .+\\(.*\\)\\s*:\\s*\\w+\\s*$` lines without bodies during refactors.","Run `pkl eval` on modules in CI to fail fast on incomplete declarations."],"tags":["pkl","ast-builder","missing-body","compile-error"],"backgroundTag":"abstract-method-not-implemented","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"}