apple/pkl · error · VmException
methodNotDefined1
methodNotDefined1
Error message
methodNotDefined1
What it means
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.
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.
Example fix
// before names.joinToString(sep) // after (when sep is accidentally an Int count) names.joinToString(sep.toString())
Defensive patterns
Strategy: type-guard
Validate before calling
// Pkl: assert the argument type before the stdlib call assert(isString(sep), "joinToString separator must be a String")
Type guard
function isString(x) = x is String // also: x is Int, x != null checks before the call
Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
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
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/5017bdb5c4f84c48.
Report an issue: GitHub.
Appendix: source
Thrown at pkl-core/src/main/java/org/pkl/core/stdlib/ExternalMethod1Node.java:31
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pkl.core.stdlib;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.NodeChild;
import org.pkl.core.ast.ExpressionNode;
import org.pkl.core.runtime.VmUtils;
@NodeChild(value = "arg1Node", type = ExpressionNode.class)
public abstract class ExternalMethod1Node extends ExternalMethodNode {
public abstract ExpressionNode getArg1Node();
@Fallback
@TruffleBoundary
protected Object fallback(@SuppressWarnings("unused") Object receiver, Object argument) {
throw exceptionBuilder()
.evalError("methodNotDefined1", getQualifiedMemberName(), VmUtils.getClass(argument))
.withProgramValue("Argument", argument)
.build();
}
public interface Factory {
ExternalMethod1Node create(ExpressionNode receiverNode, ExpressionNode arg1Node);
}
}
View on GitHub (pinned to f3efcbfc9b)