{"record":{"id":"11374a0e5b0c68ff","repo":"apple/pkl","slug":"cannotamendpropertydefinition","errorCode":"cannotAmendPropertyDefinition","errorMessage":"cannotAmendPropertyDefinition","messagePattern":"cannotAmendPropertyDefinition","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java","lineNumber":2078,"sourceCode":"    var annotationNodes = doVisitAnnotations(annotations, propertyName);\n\n    return symbolTable.enterProperty(\n        propertyName,\n        getConstLevel(modifiers),\n        scope -> {\n          ExpressionNode bodyNode;\n\n          if (expr != null) { // prop = expr\n            if (VmModifier.isExternal(modifiers)) {\n              throw exceptionBuilder()\n                  .evalError(\"externalMemberCannotHaveBody\")\n                  .withSourceSection(headerSection)\n                  .build();\n            }\n            bodyNode = visitExpr(expr);\n          } else if (!objectBodies.isEmpty()) { // prop { ... }\n            if (typeAnnotation != null) {\n              throw exceptionBuilder()\n                  .evalError(\"cannotAmendPropertyDefinition\")\n                  .withSourceSection(createSourceSection(entry))\n                  .build();\n            }\n            bodyNode =\n                doVisitObjectBody(\n                    objectBodies,\n                    new ReadSuperPropertyNode(\n                        unavailableSourceSection(),\n                        scope.getName(),\n                        scope.getConstLevel() == ConstLevel.ALL));\n          } else { // no value given\n            if (isLocal) {\n              assert typeAnnotation != null;\n              throw missingLocalPropertyValue(typeAnnotation);\n            }\n            if (VmModifier.isExternal(modifiers)) {\n              bodyNode =","sourceCodeStart":2060,"sourceCodeEnd":2096,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java#L2060-L2096","documentation":"When a property is defined with both a type annotation and an object body (`prop: Type { ... }`) inside an amendment, Pkl cannot tell whether you intend to define or amend the property, so it rejects the combination with cannotAmendPropertyDefinition, pointing at the whole definition entry. Object bodies without a type annotation are treated as amendments of the existing property.","triggerScenarios":"Writing `prop: SomeType { ... }` where the property has no `= expr` value, a non-empty object body, and a non-null typeAnnotation, in a context where the property amends an existing definition.","commonSituations":"Amending an object-typed property in a layered config while copy-pasting its type annotation along; adding member bodies to an inherited object property.","solutions":["Drop the type annotation: `prop { ... }` amends the existing property.","Provide an explicit value (`prop: Type = new Type { ... }`) if you intend a full redefinition.","Mark the property `local` if it is a genuinely new definition."],"exampleFix":"// before (in an amendment)\nserver: Server { port = 8080 }\n\n// after\nserver { port = 8080 }","handlingStrategy":"validation","validationCode":"// In amendments, reject `prop: Type { ... }` combined forms:\nif (isAmendment && propTypeAnnotation != null && hasObjectBody(prop) && propValueExpr == null) {\n  report(prop, \"drop the type annotation or provide an explicit value\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Amend with bare `prop { ... }`; annotate only in the base definition.","Use `prop: Type = new Type { ... }` for explicit redefinitions.","Configure editors/formatters to strip annotations on overridden properties."],"tags":["pkl","ast","amendment","object-body"],"backgroundTag":"invalid-config-value","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}