{"record":{"id":"a21c6cc3d726702b","repo":"apple/pkl","slug":"methodnotdefined3","errorCode":"methodNotDefined3","errorMessage":"methodNotDefined3","messagePattern":"methodNotDefined3","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/stdlib/ExternalMethod3Node.java","lineNumber":38,"sourceCode":"import com.oracle.truffle.api.dsl.NodeChild;\nimport org.pkl.core.ast.ExpressionNode;\nimport org.pkl.core.runtime.VmUtils;\n\n@NodeChild(value = \"arg1Node\", type = ExpressionNode.class)\n@NodeChild(value = \"arg2Node\", type = ExpressionNode.class)\n@NodeChild(value = \"arg3Node\", type = ExpressionNode.class)\npublic abstract class ExternalMethod3Node extends ExternalMethodNode {\n  protected abstract ExpressionNode getArg1Node();\n\n  protected abstract ExpressionNode getArg2Node();\n\n  protected abstract ExpressionNode getArg3Node();\n\n  @Fallback\n  @TruffleBoundary\n  protected Object fallback(\n      @SuppressWarnings(\"unused\") Object receiver, Object arg1, Object arg2, Object arg3) {\n    throw exceptionBuilder()\n        .evalError(\n            \"methodNotDefined3\",\n            getQualifiedMemberName(),\n            VmUtils.getClass(arg1),\n            VmUtils.getClass(arg2),\n            VmUtils.getClass(arg3))\n        .withProgramValue(\"Argument 1\", arg1)\n        .withProgramValue(\"Argument 2\", arg2)\n        .withProgramValue(\"Argument 3\", arg3)\n        .build();\n  }\n\n  public interface Factory {\n    ExternalMethod3Node create(\n        ExpressionNode receiverNode,\n        ExpressionNode arg1Node,\n        ExpressionNode arg2Node,\n        ExpressionNode arg3Node);","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/stdlib/ExternalMethod3Node.java#L20-L56","documentation":"ExternalMethod3Node implements three-argument stdlib methods. The @Fallback fires when the dynamic types of receiver + three arguments match no defined specialization, producing the \"methodNotDefined3\" eval error with the member name and each argument's class. It is Pkl's way of saying 'no overload for these types'.","triggerScenarios":"Calling a three-argument stdlib method (e.g. List.sort with comparator args, String.take/drop variants) where one or more of the three arguments has an unexpected type (null, List where Function expected, etc.).","commonSituations":"Passing a lambda where a List or Int is expected (or vice versa); a null slipping through from an amending default; copy-paste between similar methods with different signatures.","solutions":["Match each reported argument class to the documented parameter types.","Wrap or convert arguments (lambdas vs values, Int vs String) explicitly.","Print/debug the argument values with `trace()` to find which one diverges from expectation.","Consult the stdlib docs for the exact three-argument overload in your Pkl version."],"exampleFix":"// before\nlist.fold(list, init, acc) // wrong: fold(init, (acc, elem) -> ...) two-arg form\n// after\nlist.fold(init) { acc, elem -> acc + elem }","handlingStrategy":"type-guard","validationCode":"// Pkl\nassert(isFunction(f) || isClass(f), \"3rd argument must be a function or class\")","typeGuard":"function isFunction(x) = x is Function","tryCatchPattern":null,"preventionTips":["Break five/six positional arguments into named locals so types are visible","Trace() each argument once when a methodNotDefined error first appears","Keep lambdas and plain values distinct; do not pass null where a function is required"],"tags":["pkl","type-mismatch","method-resolution"],"backgroundTag":"invalid-argument-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"}