{"record":{"id":"5361366077a7065c","repo":"apple/pkl","slug":"methodnotdefined4","errorCode":"methodNotDefined4","errorMessage":"methodNotDefined4","messagePattern":"methodNotDefined4","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/stdlib/ExternalMethod4Node.java","lineNumber":45,"sourceCode":"@NodeChild(value = \"arg4Node\", type = ExpressionNode.class)\npublic abstract class ExternalMethod4Node extends ExternalMethodNode {\n  protected abstract ExpressionNode getArg1Node();\n\n  protected abstract ExpressionNode getArg2Node();\n\n  protected abstract ExpressionNode getArg3Node();\n\n  protected abstract ExpressionNode getArg4Node();\n\n  @Fallback\n  @TruffleBoundary\n  protected Object fallback(\n      @SuppressWarnings(\"unused\") Object receiver,\n      Object arg1,\n      Object arg2,\n      Object arg3,\n      Object arg4) {\n    throw exceptionBuilder()\n        .evalError(\n            \"methodNotDefined4\",\n            getQualifiedMemberName(),\n            VmUtils.getClass(arg1),\n            VmUtils.getClass(arg2),\n            VmUtils.getClass(arg3),\n            VmUtils.getClass(arg4))\n        .withProgramValue(\"Argument 1\", arg1)\n        .withProgramValue(\"Argument 2\", arg2)\n        .withProgramValue(\"Argument 3\", arg3)\n        .withProgramValue(\"Argument 4\", arg4)\n        .build();\n  }\n\n  public interface Factory {\n    ExternalMethod4Node create(\n        ExpressionNode receiverNode,\n        ExpressionNode arg1Node,","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/stdlib/ExternalMethod4Node.java#L27-L63","documentation":"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.","triggerScenarios":"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.","commonSituations":"Wrong arity/type from a helper function returning a differently-shaped tuple; misunderstanding which overload the trailing arguments select; nulls from optional properties.","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."],"exampleFix":"// before\nstr.replaceAll(regex, replacement, /* regexFlags */ true)\n// after\nstr.replaceAll(regex, replacement, 0) // Int flags, not Boolean","handlingStrategy":"type-guard","validationCode":"// Pkl\nassert(isInt(flags), \"flags argument must be an Int\")","typeGuard":"function isInt(x) = x is Int","tryCatchPattern":null,"preventionTips":["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"],"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"}