{"record":{"id":"5017bdb5c4f84c48","repo":"apple/pkl","slug":"methodnotdefined1","errorCode":"methodNotDefined1","errorMessage":"methodNotDefined1","messagePattern":"methodNotDefined1","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/stdlib/ExternalMethod1Node.java","lineNumber":31,"sourceCode":" * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage 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)\npublic abstract class ExternalMethod1Node extends ExternalMethodNode {\n  public abstract ExpressionNode getArg1Node();\n\n  @Fallback\n  @TruffleBoundary\n  protected Object fallback(@SuppressWarnings(\"unused\") Object receiver, Object argument) {\n    throw exceptionBuilder()\n        .evalError(\"methodNotDefined1\", getQualifiedMemberName(), VmUtils.getClass(argument))\n        .withProgramValue(\"Argument\", argument)\n        .build();\n  }\n\n  public interface Factory {\n    ExternalMethod1Node create(ExpressionNode receiverNode, ExpressionNode arg1Node);\n  }\n}\n","sourceCodeStart":13,"sourceCodeEnd":41,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/stdlib/ExternalMethod1Node.java#L13-L41","documentation":"ExternalMethod1Node is the Truffle node base class for Pkl stdlib methods taking one argument. If no type-specialized execution path matches the (receiver class, argument class) pair, the @Fallback method runs and throws the \"methodNotDefined1\" eval error, naming the qualified member and the argument's actual class. It means the stdlib method does not support that argument type.","triggerScenarios":"Calling a one-argument stdlib method (e.g. a List/Map/String method) with an argument whose type is not in its overload set — e.g. passing a String where an Int is expected, or null, or a concrete object/Class where a Function was expected.","commonSituations":"Config typo passing the wrong property; value became null due to an earlier default; Pkl version change where a type overload was removed; passing `this` or a module where a simpler type was expected.","solutions":["Read the error's reported argument class and compare with the method's documented parameter type.","Convert the argument explicitly: `.toInt()`, `.toString()`, `.toRegex()`, etc., before the call.","Check for null/unset propagation — use the null-coalescing or `??` default to supply a correct value.","Verify the method overload exists in your Pkl version's stdlib docs."],"exampleFix":"// before\nnames.joinToString(sep)\n// after (when sep is accidentally an Int count)\nnames.joinToString(sep.toString())","handlingStrategy":"type-guard","validationCode":"// Pkl: assert the argument type before the stdlib call\nassert(isString(sep), \"joinToString separator must be a String\")","typeGuard":"function isString(x) = x is String\n// also: x is Int, x != null checks before the call","tryCatchPattern":null,"preventionTips":["Check the argument's class in the error message against the stdlib docs","Convert explicitly (.toString()/.toInt()) instead of relying on implicit types","Trace values upstream when they come from defaults or interop data"],"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"}