apple/pkl · error · VmException
methodNotDefined4
methodNotDefined4
Error message
methodNotDefined4
What it means
ExternalMethod4Node implements four-argument stdlib methods. When the runtime dispatch finds no type-specialized path for the receiver and the four argument types, the @Fallback throws "methodNotDefined4" naming the method and all four argument classes. No overload accepts that combination.
Source
Thrown at pkl-core/src/main/java/org/pkl/core/stdlib/ExternalMethod4Node.java:45
@NodeChild(value = "arg4Node", type = ExpressionNode.class)
public abstract class ExternalMethod4Node extends ExternalMethodNode {
protected abstract ExpressionNode getArg1Node();
protected abstract ExpressionNode getArg2Node();
protected abstract ExpressionNode getArg3Node();
protected abstract ExpressionNode getArg4Node();
@Fallback
@TruffleBoundary
protected Object fallback(
@SuppressWarnings("unused") Object receiver,
Object arg1,
Object arg2,
Object arg3,
Object arg4) {
throw exceptionBuilder()
.evalError(
"methodNotDefined4",
getQualifiedMemberName(),
VmUtils.getClass(arg1),
VmUtils.getClass(arg2),
VmUtils.getClass(arg3),
VmUtils.getClass(arg4))
.withProgramValue("Argument 1", arg1)
.withProgramValue("Argument 2", arg2)
.withProgramValue("Argument 3", arg3)
.withProgramValue("Argument 4", arg4)
.build();
}
public interface Factory {
ExternalMethod4Node create(
ExpressionNode receiverNode,
ExpressionNode arg1Node,View on GitHub (pinned to f3efcbfc9b)
Solutions
- Verify all four argument classes from the error against the stdlib signature.
- Correct or convert each mismatched argument explicitly.
- If a helper produces the arguments, trace its output types first.
- Check Pkl stdlib changelog for signature changes across versions.
Example fix
// before str.replaceAll(regex, replacement, /* regexFlags */ true) // after str.replaceAll(regex, replacement, 0) // Int flags, not Boolean
Defensive patterns
Strategy: type-guard
Validate before calling
// Pkl assert(isInt(flags), "flags argument must be an Int")
Type guard
function isInt(x) = x is Int
Prevention
- Read all four reported argument classes in the error before changing code
- Document and test helper functions that build stdlib argument tuples
- Re-check trailing optional arguments after refactors
When it happens
Trigger: Calling a four-argument stdlib method with any argument of an unsupported type — often the later positional arguments (flags/defaults) given wrong types, e.g. passing a Boolean where an Int is expected.
Common situations: Wrong arity/type from a helper function returning a differently-shaped tuple; misunderstanding which overload the trailing arguments select; nulls from optional properties.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- methodNotDefined1
- methodNotDefined2
- methodNotDefined3
- methodNotDefined5
- Error converting property `%s` in Pkl object of type `%s` to
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/5361366077a7065c.
Report an issue: GitHub.