{"record":{"id":"48a27e99816b1896","repo":"apple/pkl","slug":"wrongargumentcount","errorCode":"wrongArgumentCount","errorMessage":"wrongArgumentCount","messagePattern":"wrongArgumentCount","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/member/FunctionNode.java","lineNumber":113,"sourceCode":"    var sb = new StringBuilder(member.getName().toString());\n    sb.append('(');\n    for (var i = 0; i < Math.min(getFrameDescriptor().getNumberOfSlots(), paramCount); i++) {\n      if (i > 0) {\n        sb.append(\", \");\n      }\n      sb.append(getFrameDescriptor().getSlotName(i));\n    }\n    sb.append(')');\n    return sb.toString();\n  }\n\n  @Override\n  @ExplodeLoop\n  protected Object executeImpl(VirtualFrame frame) {\n    var totalArgCount = frame.getArguments().length;\n    if (totalArgCount != totalParamCount) {\n      CompilerDirectives.transferToInterpreter();\n      throw wrongArgumentCount(totalArgCount - IMPLICIT_PARAM_COUNT);\n    }\n\n    for (var i = 0; i < parameterTypeNodes.length; i++) {\n      var argument = frame.getArguments()[IMPLICIT_PARAM_COUNT + i];\n      parameterTypeNodes[i].executeAndSet(frame, argument);\n    }\n\n    var result = bodyNode.executeGeneric(frame);\n\n    if (checkedReturnTypeNode != null) {\n      return checkedReturnTypeNode.execute(frame, result);\n    }\n\n    return result;\n  }\n\n  public VmMap getParameterMirrors() {\n    var builder = VmMap.builder();","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/member/FunctionNode.java#L95-L131","documentation":"Pkl throws wrongArgumentCount when a function is invoked with a number of arguments that does not match its declared parameter count. FunctionNode.executeImpl compares the frame's argument count (minus implicit receiver parameters) against totalParamCount and raises the error listing expected vs actual counts. Pkl functions have fixed arity — no overloads or default arguments bridge a mismatch.","triggerScenarios":"Calling a Pkl function with too few or too many arguments; passing a function reference with a different signature where a fixed-arity function is expected; library function signature changed between versions while caller was not updated; miscounting implicit receiver/owner parameters in generated calls.","commonSituations":"Upgrading a package whose function gained or lost a parameter; hand-writing calls to generated or standard-library functions; invoking a two-parameter function inside a `let` or default-value expression with leftover arguments from a refactor.","solutions":["Read expected vs actual counts from the error message and add or remove arguments at the call site to match.","Check the function's current signature in the imported module/package — a version change may have altered arity.","If arguments are optional by design, provide the new required value or use the library's default-preserving overload.","Pin the package version or update call sites when upgrading dependencies."],"exampleFix":"// before\njoin(\"-\", parts, \" \")  // extra argument\n\n// after\njoin(\"-\", parts)","handlingStrategy":"type-guard","validationCode":"// Check arity against the imported module's declaration before calling:\n// import \"lib.pkl\"\n// lib.join has (sep, values) -> call with exactly 2 arguments.","typeGuard":"// Prefer typed function references in Pkl:\n// f: (String, List<String>) -> String = lib.join\n// mis-arity calls then fail type checking instead of at runtime.","tryCatchPattern":null,"preventionTips":["Use typed function references so arity mismatches surface at type-check time.","Read the function signature before calling, especially for package functions.","Pin package versions; update call sites when signatures change on upgrade.","Let pkl-lsp autocomplete insert the correct argument list."],"tags":["pkl","function-call","arity","argument-count"],"backgroundTag":"missing-required-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"}