{"record":{"id":"db156c7bdcacf41f","repo":"stanfordnlp/CoreNLP","slug":"cannot-find-function-matching-args-function-ar","errorCode":null,"errorMessage":"Cannot find function matching args: ${function}\nArgs are: ${evaled}\nOptions are:\n${fs}","messagePattern":"Cannot find function matching args: (.+?)\nArgs are: (.+?)\nOptions are:\n(.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ling/tokensregex/types/Expressions.java","lineNumber":951,"sourceCode":"        List<Value> evaled = new ArrayList<>();\n        for (Expression param:params) {\n          evaled.add(param.evaluate(env, args));\n        }\n        Collection<ValueFunction> fs = (Collection<ValueFunction>) funcValue;\n        for (ValueFunction f:fs) {\n          if (f.checkArgs(evaled)) {\n            return f.apply(env, evaled);\n          }\n        }\n        StringBuilder sb = new StringBuilder();\n        sb.append(\"Cannot find function matching args: \" + function + NEWLINE);\n        sb.append(\"Args are: \" + StringUtils.join(evaled, \",\") + NEWLINE);\n        if (fs.size() > 0) {\n          sb.append(\"Options are:\\n\" + StringUtils.join(fs, NEWLINE));\n        } else {\n          sb.append(\"No options\");\n        }\n        throw new RuntimeException(sb.toString());\n      } else if (funcValue instanceof Class) {\n        Class c = (Class) funcValue;\n        List<Value> evaled = new ArrayList<>();\n        for (Expression param:params) {\n          evaled.add(param.evaluate(env, args));\n        }\n        Class[] paramTypes = new Class[params.size()];\n        Object[] objs = new Object[params.size()];\n        boolean paramsNotNull = true;\n        for (int i = 0; i < params.size(); i++) {\n          Value v = evaled.get(i);\n          if (v != null) {\n            objs[i] = v.get();\n            if (objs[i] != null) {\n              paramTypes[i] = objs[i].getClass();\n            } else {\n              paramTypes[i] = null;\n              paramsNotNull = false;","sourceCodeStart":933,"sourceCodeEnd":969,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ling/tokensregex/types/Expressions.java#L933-L969","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n$FUNC(\"5\")   // expects Integer\n// after\n$FUNC(5)","handlingStrategy":"type-guard","validationCode":"Object f = ValueFunctions.lookupFunctionObject(env, functionName);\n// compare expected arg types against evaluated params before invoking\nfor (Expression p : params) {\n    Object v = p.evaluate(env).get();\n    // assert v matches a declared signature type\n}","typeGuard":null,"tryCatchPattern":"try {\n    Value v = expr.evaluate(env, args);\n} catch (RuntimeException e) {\n    if (e.getMessage().contains(\"Cannot find function matching args\")) {\n        // parse 'Options are:' from message and log expected signatures\n    } else throw e;\n}","preventionTips":["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"],"tags":["tokensregex","expression-language","argument-mismatch"],"backgroundTag":"invalid-argument-value","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}