{"record":{"id":"0d3785d1e7d9fca7","repo":"apple/pkl","slug":"listingamendmentcannothaveparameters","errorCode":"listingAmendmentCannotHaveParameters","errorMessage":"Expected a function that returns a `Listing`, but got a `Listing`.","messagePattern":"Expected a function that returns a `Listing`, but got a `Listing`\\.","errorType":"exception","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/expression/generator/GeneratorObjectLiteralNode.java","lineNumber":248,"sourceCode":"  }\n\n  @Idempotent\n  protected boolean checkObjectCannotHaveParameters() {\n    if (parametersDescriptor == null) return true;\n\n    CompilerDirectives.transferToInterpreter();\n    throw exceptionBuilder()\n        .evalError(\"objectAmendmentCannotHaveParameters\")\n        .withLocation(getParentNode())\n        .build();\n  }\n\n  @Idempotent\n  protected boolean checkListingCannotHaveParameters() {\n    if (parametersDescriptor == null) return true;\n\n    CompilerDirectives.transferToInterpreter();\n    throw exceptionBuilder()\n        .evalError(\"listingAmendmentCannotHaveParameters\")\n        .withLocation(getParentNode())\n        .build();\n  }\n\n  @Idempotent\n  protected boolean checkMappingCannotHaveParameters() {\n    if (parametersDescriptor == null) return true;\n\n    CompilerDirectives.transferToInterpreter();\n    throw exceptionBuilder()\n        .evalError(\"mappingAmendmentCannotHaveParameters\")\n        .withLocation(getParentNode())\n        .build();\n  }\n\n  @ExplodeLoop\n  private ObjectData executeChildren(VirtualFrame frame, Object parent, int parentLength) {","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/expression/generator/GeneratorObjectLiteralNode.java#L230-L266","documentation":"An amendment applied to a Listing must not declare parameters. If the target already is a Listing (not a function returning a Listing), supplying `(param) -> ...` amendment syntax is invalid and rejected by `checkListingCannotHaveParameters`.","triggerScenarios":"`someListing { (x) -> ... }` where `someListing` is already a Listing value rather than a function returning a Listing; the parametersDescriptor is non-null while the resolved parent is a Listing.","commonSituations":"Copy-pasting a function-style amendment onto an existing Listing property; mixing `->` function syntax with object-literal amendment braces; refactoring a function-returned Listing into a plain Listing while keeping parameters.","solutions":["Drop the parameter list and amend the Listing entries directly (`someListing { ... { ... } }`).","If element-wise transformation is needed, use `for` generators or `map` on the Listing instead of amendment parameters.","If a function is intended, invoke it with arguments before amending the returned Listing."],"exampleFix":"// before\nservers { (env) ->\n  new { name = env }\n}\n// after\nservers {\n  new { name = \"prod\" }\n}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never add a parameter list to amendments of Listing-valued properties.","Use `for` generators or `map` for element-wise transformations.","Call the underlying function with arguments before amending its result."],"tags":["pkl","listing","amendment","parameters"],"backgroundTag":"invalid-argument","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"}