{"record":{"id":"c0c3b6d4f84cd3ac","repo":"stanfordnlp/CoreNLP","slug":"2-arguments-expected-got-in-size","errorCode":null,"errorMessage":"2 arguments expected, got ${in.size()}","messagePattern":"2 arguments expected, got (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ling/tokensregex/types/ValueFunctions.java","lineNumber":787,"sourceCode":"    public boolean checkArgs(List<Value> in) {\n      if (in.size() != 2) {\n        return false;\n      }\n      if (clazz != null) {\n        if (in.get(0) == null || in.get(0).get() == null || !(clazz.isAssignableFrom(in.get(0).get().getClass()))) {\n          return false;\n        }\n        if (in.get(1) == null || in.get(1).get() == null || !(clazz.isAssignableFrom(in.get(1).get().getClass()))) {\n          return false;\n        }\n      }\n      return true;\n    }\n\n    @Override\n    public Value apply(Env env, List<Value> in) {\n      if (in.size() != 2) {\n        throw new IllegalArgumentException(\"2 arguments expected, got \" + in.size());\n      }\n      if (in.get(0) == null || in.get(1) == null || in.get(0).get() == null || in.get(1).get() == null) {\n        return null; // Can't compare...\n      }\n      Boolean res = compare((T) in.get(0).get(), (T) in.get(1).get());\n      return (res)? Expressions.TRUE: Expressions.FALSE;\n    }\n  }\n\n  public static final ValueFunction NOT_EQUALS_FUNCTION = new NamedValueFunction(\"EQUALS\") {\n    @Override\n    public String getParamDesc() {\n      return \"Object,Object\";\n    }\n\n    @Override\n    public boolean checkArgs(List<Value> in) {\n      return in.size() == 2;","sourceCodeStart":769,"sourceCodeEnd":805,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ling/tokensregex/types/ValueFunctions.java#L769-L805","documentation":"The typed comparison ValueFunction (e.g. NUMBER compare) requires exactly two arguments and throws IllegalArgumentException when apply() receives any other count. The comparison produces TRUE/FALSE based on comparing the two values.","triggerScenarios":"Calling a compare-style ValueFunction with in.size() != 2, e.g. apply(env, singletonList(v)) with one value or three values, or expression text like GT(5) missing an operand.","commonSituations":"Typos in expression strings omitting an operand, programmatic apply() calls without checkArgs, dynamically generated expressions where a variable evaluated to nothing and dropped an argument.","solutions":["Supply exactly two arguments to the comparison function in the expression.","Call checkArgs(in) before apply() and handle the false case.","Fix dynamic expression builders so missing variables don't reduce the argument count."],"exampleFix":"// before\nValue v = ValueFunctions.of(\"GT\").apply(env, Arrays.asList(a));\n// after\nValue v = ValueFunctions.of(\"GT\").apply(env, Arrays.asList(a, b));","handlingStrategy":"validation","validationCode":"if (args == null || args.size() != 2) throw new IllegalArgumentException(\"Compare needs exactly 2 args\");","typeGuard":"boolean isBinary(List<Value> in) { return in != null && in.size() == 2; }","tryCatchPattern":"try {\n    v = cmpFn.apply(env, args);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"2 arguments expected\")) {\n        v = null; // handle missing operand\n    } else throw e;\n}","preventionTips":["Always pass both operands to comparison functions","Run checkArgs() before apply()","Test generated expressions for missing operands"],"tags":["tokensregex","argument-count","comparison"],"backgroundTag":"missing-required-argument","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"}