apple/pkl · error
wrongFunctionArgumentCount
wrongFunctionArgumentCount
Error message
wrongFunctionArgumentCount
What it means
`wrongFunctionArgumentCount` is thrown by IdentityMixinNode when the generated mixin identity function is invoked with the wrong number of arguments. The node expects a receiver plus exactly 1 argument (frame arguments length 3); any other count is a call-site arity error. The message states the expected count (1) versus the actual count.
Source
Thrown at pkl-core/src/main/java/org/pkl/core/ast/type/IdentityMixinNode.java:59
this.argumentTypeNode = argumentTypeNode;
}
@Override
public SourceSection getSourceSection() {
return sourceSection;
}
@Override
public String getName() {
return qualifiedName;
}
@Override
protected Object executeImpl(VirtualFrame frame) {
var arguments = frame.getArguments();
if (arguments.length != 3) {
CompilerDirectives.transferToInterpreter();
throw exceptionBuilder()
.evalError("wrongFunctionArgumentCount", 1, arguments.length - 2, "")
.withSourceSection(sourceSection)
.build();
}
var argument = arguments[2];
if (argumentTypeNode != null) {
return argumentTypeNode.execute(frame, argument);
}
return argument;
}
}
View on GitHub (pinned to f3efcbfc9b)
Solutions
- Call the function with exactly one argument
- Remove extra arguments or supply the missing one at the call site
- Check the function's declared parameter list and update all call sites
Example fix
// before mixinIdentity() // after mixinIdentity(value)
Defensive patterns
Strategy: validation
Validate before calling
// check arity before invoking
if (typeof fn === "function" && fn.length !== 1) throw new Error("expected exactly 1 argument"); Prevention
- Match call-site arguments to the declared parameter count
- Re-grep call sites after changing a function signature
When it happens
Trigger: Calling a Pkl function that compiles to this mixin identity function with 0 or more than 1 argument, e.g. `foo()` or `foo(a, b)` instead of `foo(a)`.
Common situations: Calling a property-like function with parentheses but wrong arity; copy-paste call sites after a signature change; misreading a zero-argument property as a function.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- wrongArgumentCount
- tooManyFunctionParameters
- wrongTypeArgumentCount
- Node `%s` of type `%s` does not have a property named `%s`.
- JavaType token must be parameterized.
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/7b4786ae6cb7ca99.
Report an issue: GitHub.