{"record":{"id":"bcec9dd880e1eee1","repo":"apple/pkl","slug":"methodnotdefined2","errorCode":"methodNotDefined2","errorMessage":"methodNotDefined2","messagePattern":"methodNotDefined2","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/stdlib/ExternalMethod2Node.java","lineNumber":34,"sourceCode":"package org.pkl.core.stdlib;\n\nimport com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;\nimport com.oracle.truffle.api.dsl.Fallback;\nimport 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)\npublic abstract class ExternalMethod2Node extends ExternalMethodNode {\n  protected abstract ExpressionNode getArg1Node();\n\n  protected abstract ExpressionNode getArg2Node();\n\n  @Fallback\n  @TruffleBoundary\n  protected Object fallback(@SuppressWarnings(\"unused\") Object receiver, Object arg1, Object arg2) {\n    throw exceptionBuilder()\n        .evalError(\n            \"methodNotDefined2\",\n            getQualifiedMemberName(),\n            VmUtils.getClass(arg1),\n            VmUtils.getClass(arg2))\n        .withProgramValue(\"Argument 1\", arg1)\n        .withProgramValue(\"Argument 2\", arg2)\n        .build();\n  }\n\n  public interface Factory {\n    ExternalMethod2Node create(\n        ExpressionNode receiverNode, ExpressionNode arg1Node, ExpressionNode arg2Node);\n  }\n}\n","sourceCodeStart":16,"sourceCodeEnd":50,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/stdlib/ExternalMethod2Node.java#L16-L50","documentation":"ExternalMethod2Node backs Pkl stdlib methods with two arguments. When no specialized node matches the receiver and both argument types, the @Fallback throws \"methodNotDefined2\" listing the method name and both argument classes. It signals that the two-argument overload does not accept that type combination.","triggerScenarios":"Calling a two-argument stdlib method with wrong types in either slot — e.g. Map.getOrNull with a non-key type, String.replace with Int arguments, or swapping the intended argument order.","commonSituations":"Swapped arguments (value/position); a variable holding the wrong type due to an upstream default; API drift between Pkl versions for the method signature.","solutions":["Check both reported argument classes against the method's signature in the stdlib docs.","Insert explicit conversions (.toString(), .toInt(), .toBoolean()) on the offending argument.","Fix argument order if the types look transposed.","Pin/upgrade the Pkl version if the overload set changed between releases."],"exampleFix":"// before\nstr.replace(find, /* limit */ \"all\")\n// after\nstr.replace(find, 0) // Int limit, not String","handlingStrategy":"type-guard","validationCode":"// Pkl\nassert(isString(find) && isString(replacement), \"replace args must be Strings\")","typeGuard":"function areStrings2(a, b) = a is String && b is String","tryCatchPattern":null,"preventionTips":["Verify argument order and types against the two-arg signature","Avoid passing optional/null properties directly into stdlib calls","Pin the Pkl version and re-check signatures after upgrades"],"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"}