stanfordnlp/CoreNLP · error · RuntimeException
Cannot find function matching args
Error message
Cannot find function matching args: ${function}
Args are: ${evaled}
Options are:
${fs} What it means
The function name resolved to something callable, but none of its overloads/signatures accept the argument types actually evaluated. The library builds a diagnostic message listing the evaluated args and the candidate signatures it considered, then throws.
Solutions
- Match argument count and types to one of the printed 'Options are:' signatures in the exception message
- Add explicit type coercion in the rule, e.g. pass `1` instead of `"1"` or wrap args in INT()/STRING() style conversions if available
- Register an additional ValueFunction overload accepting the argument types you pass
- Check whether a library upgrade changed the function's signature
Example fix
// before
$FUNC("5") // expects Integer
// after
$FUNC(5) Defensive patterns
Strategy: type-guard
Validate before calling
Object f = ValueFunctions.lookupFunctionObject(env, functionName);
// compare expected arg types against evaluated params before invoking
for (Expression p : params) {
Object v = p.evaluate(env).get();
// assert v matches a declared signature type
} Try / catch
try {
Value v = expr.evaluate(env, args);
} catch (RuntimeException e) {
if (e.getMessage().contains("Cannot find function matching args")) {
// parse 'Options are:' from message and log expected signatures
} else throw e;
} Prevention
- Read the exception's 'Options are:' section — it lists every accepted signature
- Prefer numeric literals over quoted strings when functions expect numbers
- Pin CoreNLP versions and re-check function signatures after upgrades
When it happens
Trigger: Evaluating `FUNC(a, b)` where FUNC exists but no registered ValueFunction or reflected method/constructor matches the number and types of the evaluated parameters — e.g. passing a String where an Integer is expected, or the wrong argument count.
Common situations: Passing string literals where numeric literals are required (or vice versa) in TokensRegex expressions, calling a Java static method with mismatched parameter types, or overload changes after a CoreNLP upgrade.
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
- Expression was not evaluated....
- Unknown function
- Unsupported function value
- 2 arguments expected, got
- Annotation field cannot be null
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/db156c7bdcacf41f.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/ling/tokensregex/types/Expressions.java:951
List<Value> evaled = new ArrayList<>();
for (Expression param:params) {
evaled.add(param.evaluate(env, args));
}
Collection<ValueFunction> fs = (Collection<ValueFunction>) funcValue;
for (ValueFunction f:fs) {
if (f.checkArgs(evaled)) {
return f.apply(env, evaled);
}
}
StringBuilder sb = new StringBuilder();
sb.append("Cannot find function matching args: " + function + NEWLINE);
sb.append("Args are: " + StringUtils.join(evaled, ",") + NEWLINE);
if (fs.size() > 0) {
sb.append("Options are:\n" + StringUtils.join(fs, NEWLINE));
} else {
sb.append("No options");
}
throw new RuntimeException(sb.toString());
} else if (funcValue instanceof Class) {
Class c = (Class) funcValue;
List<Value> evaled = new ArrayList<>();
for (Expression param:params) {
evaled.add(param.evaluate(env, args));
}
Class[] paramTypes = new Class[params.size()];
Object[] objs = new Object[params.size()];
boolean paramsNotNull = true;
for (int i = 0; i < params.size(); i++) {
Value v = evaled.get(i);
if (v != null) {
objs[i] = v.get();
if (objs[i] != null) {
paramTypes[i] = objs[i].getClass();
} else {
paramTypes[i] = null;
paramsNotNull = false;View on GitHub (pinned to 1b7edd19c4)