{"record":{"id":"b5ea416439698ff8","repo":"stanfordnlp/CoreNLP","slug":"unhandled-case-mono-and-type","errorCode":null,"errorMessage":"Unhandled case: \" + mono + \" and \" + type","messagePattern":"Unhandled case: \" \\+ mono \\+ \" and \" \\+ type","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/naturalli/Operator.java","lineNumber":175,"sourceCode":"  public static String monotonicitySignature(Monotonicity mono, MonotonicityType type) {\n    switch (mono) {\n      case MONOTONE:\n        switch (type) {\n          case NONE: return \"nonmonotone\";\n          case ADDITIVE: return \"additive\";\n          case MULTIPLICATIVE: return \"multiplicative\";\n          case BOTH: return \"additive-multiplicative\";\n        }\n      case ANTITONE:\n        switch (type) {\n          case NONE: return \"nonmonotone\";\n          case ADDITIVE: return \"anti-additive\";\n          case MULTIPLICATIVE: return \"anti-multiplicative\";\n          case BOTH: return \"anti-additive-multiplicative\";\n        }\n      case NONMONOTONE: return \"nonmonotone\";\n    }\n    throw new IllegalStateException(\"Unhandled case: \" + mono + \" and \" + type);\n  }\n\n  @SuppressWarnings(\"UnusedDeclaration\")\n  public static final Set<String> quantifierGlosses = Collections.unmodifiableSet(new HashSet<String>() {{\n    for (Operator operator : values()) {\n      add(operator.surfaceForm);\n    }\n  }});\n\n  public static Optional<Operator> fromString(String word) {\n    String wordToLowerCase = word.toLowerCase().replaceAll(\"[0-9]\", \"--num-- \").trim();\n    for (Operator candidate : Operator.values()) {\n      if (candidate.surfaceForm.equals(wordToLowerCase)) {\n        return Optional.of(candidate);\n      }\n    }\n    return Optional.empty();\n  }","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/naturalli/Operator.java#L157-L193","documentation":"monotonicitySignature maps a Monotonicity + MonotonicityType pair back to its canonical string form (e.g. \"anti-additive\"). If the combination falls outside the enumerated matrix of monotone/antitone x additive/multiplicative/both plus NONMONOTONE, the switch returns nothing and the method throws IllegalStateException. This should be unreachable with valid enum values and signals a real logic bug if seen.","triggerScenarios":"Calling Operator.monotonicitySignature(mono, type) with a Monotonicity/MonotonicityType combination not covered by the switch — typically only possible with a null enum value, a corrupted/deserialized enum, or a newly added enum constant not yet handled.","commonSituations":"After upgrading CoreNLP and hand-crafting Operator definitions; passing null MonotonicityType for MONOTONE/NONMONOTONE cases in code that builds signatures dynamically.","solutions":["Inspect the mono and type values being passed; ensure they come from the standard Operator enum combinations","Add the missing case to the switch if a new Monotonicity/MonotonicityType constant was introduced","Guard for null before calling the method"],"exampleFix":"// before\nString sig = Operator.monotonicitySignature(mono, null);\n// after\nString sig = (mono == null || type == null) ? \"nonmonotone\" : Operator.monotonicitySignature(mono, type);","handlingStrategy":"validation","validationCode":"if (mono == null || type == null) { sig = \"nonmonotone\"; } else { sig = Operator.monotonicitySignature(mono, type); }","typeGuard":null,"tryCatchPattern":"try { sig = Operator.monotonicitySignature(mono, type); } catch (IllegalStateException e) { sig = \"nonmonotone\"; }","preventionTips":["Never pass null enum values into monotonicitySignature","Update the switch when adding enum constants"],"tags":["java","illegal-state","enum"],"backgroundTag":"internal-invariant-violation","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}