{"record":{"id":"f89a2f5e35986374","repo":"stanfordnlp/CoreNLP","slug":"unsupported-function-value-funcvalue","errorCode":null,"errorMessage":"Unsupported function value ${funcValue}","messagePattern":"Unsupported function value (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ling/tokensregex/types/Expressions.java","lineNumber":1008,"sourceCode":"            for (Constructor cons:constructors) {\n              Class[] consParamTypes = cons.getParameterTypes();\n              boolean compatible = isArgTypesCompatible(paramTypes, consParamTypes);\n              if (compatible) {\n                constructor = cons;\n                break;\n              }\n            }\n            if (constructor == null) {\n              throw new RuntimeException(\"Cannot instantiate \" + c, ex);\n            }\n          }\n          Object obj = constructor.newInstance(objs);\n          return new PrimitiveValue<>(function, obj);\n        } catch (InvocationTargetException | InstantiationException | IllegalAccessException ex) {\n          throw new RuntimeException(\"Cannot instantiate \" + c, ex);\n        }\n      } else {\n        throw new UnsupportedOperationException(\"Unsupported function value \" + funcValue);\n      }\n    }\n\n    @Override\n    public boolean equals(Object o) {\n      if (this == o) return true;\n      if (!(o instanceof FunctionCallExpression)) return false;\n\n      FunctionCallExpression that = (FunctionCallExpression) o;\n\n      if (function != null ? !function.equals(that.function) : that.function != null) return false;\n      if (params != null ? !params.equals(that.params) : that.params != null) return false;\n\n      return true;\n    }\n\n    @Override\n    public int hashCode() {","sourceCodeStart":990,"sourceCodeEnd":1026,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ling/tokensregex/types/Expressions.java#L990-L1026","documentation":"Function-call evaluation resolves the callee to one of: a ValueFunction, a Value wrapping a function, a Class (constructor call), or an object on which a method is invoked. When the resolved funcValue is none of these types, evaluate() has no dispatch path and throws UnsupportedOperationException with the value's toString.","triggerScenarios":"Binding a plain object (e.g. a String, List, or POJO) into the Env under a function-like name and then calling `NAME(args)` — the bound value is not a function, class, or invokable method holder.","commonSituations":"A rule calls what looks like a function but the env actually holds a data value under that name (name collision, e.g. bound variable shadowing a function name), or a custom binder registered the wrong object type.","solutions":["Bind a ValueFunction (or wrap the callable) under the name instead of a plain object","Rename the bound variable so it doesn't collide with a function name","Check what is actually bound: `env.lookup(name)` and confirm it is a ValueFunction or Class"],"exampleFix":"// before\nenv.bind(\"process\", resultList); // plain object\n$process(x) // -> UnsupportedOperationException\n// after\nenv.bind(\"process\", new ProcessValueFunction());","handlingStrategy":"type-guard","validationCode":"Object f = ValueFunctions.lookupFunctionObject(env, functionName);\nif (!(f instanceof ValueFunction) && !(f instanceof Value) && !(f instanceof Class)) {\n    throw new IllegalStateException(\"Name is not callable: \" + functionName);\n}","typeGuard":"boolean isCallable(Object f) {\n    return f instanceof ValueFunction || f instanceof Value || f instanceof Class;\n}","tryCatchPattern":"try {\n    Value v = expr.evaluate(env, args);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage().startsWith(\"Unsupported function value\")) {\n        // rebind the name to a ValueFunction and retry\n    } else throw e;\n}","preventionTips":["Namespace function names distinctly from variable names to avoid collisions","Only bind ValueFunction, Value-wrapping functions, or Class objects under callable names","Audit env.bind calls for accidental plain-object bindings"],"tags":["tokensregex","expression-language","unsupported-operation"],"backgroundTag":"unsupported-operation","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"}