{"record":{"id":"e7ae2d49b45953f6","repo":"stanfordnlp/CoreNLP","slug":"prev-immediate-not-implemented-for-arg1-arg1-get","errorCode":null,"errorMessage":"PREV_IMMEDIATE not implemented for arg1=${arg1.getClass()}, arg2=${arg2.getClass()}","messagePattern":"PREV_IMMEDIATE not implemented for arg1=(.+?), arg2=(.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/time/SUTime.java","lineNumber":1123,"sourceCode":"        // if (arg1 == null || arg2Prev == null) { return arg2Prev; }\n        if (arg1 instanceof Time) {\n          Time t = (Time) arg1;\n          if (arg2 instanceof Duration) {\n            return ((Duration) arg2).toTime(t, flags | RESOLVE_TO_PAST);\n          } else {\n            // TODO: flags?\n            Temporal resolvedThis = arg2.resolve(t, RESOLVE_TO_PAST);\n            if (resolvedThis != null) {\n              if (resolvedThis instanceof Time) {\n                if (((Time) resolvedThis).compareTo(t) >= 0) {\n                  return PREV.apply(arg1, arg2);\n                }\n              }\n            }\n            return resolvedThis;\n          }\n        } else {\n          throw new UnsupportedOperationException(\"PREV_IMMEDIATE not implemented for arg1=\" + arg1.getClass() + \", arg2=\" + arg2.getClass());\n        }\n      }\n    },\n    UNION {\n      @Override\n      public Temporal apply(Temporal arg1, Temporal arg2, int flags) {\n        if (arg1 == null) {\n          return arg2;\n        }\n        if (arg2 == null) {\n          return arg1;\n        }\n        // return arg1.union(arg2);\n        throw new UnsupportedOperationException(\"UNION not implemented for arg1=\" + arg1.getClass() + \", arg2=\" + arg2.getClass());\n      }\n    },\n    INTERSECT {\n      @Override","sourceCodeStart":1105,"sourceCodeEnd":1141,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/time/SUTime.java#L1105-L1141","documentation":"TemporalOp.PREV_IMMEDIATE ('this past Friday') resolves arg2 to the immediately preceding instance relative to arg1, which must be a Time. A non-Time arg1 has no implemented semantics, so UnsupportedOperationException is thrown naming both argument classes.","triggerScenarios":"Calling SUTime.TemporalOp.PREV_IMMEDIATE.apply(arg1, arg2, flags) where arg1 is a Duration/Range rather than a Time, usually from custom temporal rules.","commonSituations":"Parsing 'this past week' phrases where the reference date was mis-parsed; incorrect argument ordering in code that drives TemporalOp directly.","solutions":["Convert or resolve arg1 to a SUTime.Time before applying the operator","Use the class names in the message to locate and fix the offending rule/call site","Guard with instanceof Time and provide an explicit alternative path","Upgrade or file an issue with CoreNLP if triggered by a built-in rule"],"exampleFix":"// before\nTemporalOp.PREV_IMMEDIATE.apply(arg1, arg2, flags);\n// after\nif (!(arg1 instanceof Time)) { arg1 = arg1.getRange().end(); }\nTemporalOp.PREV_IMMEDIATE.apply(arg1, arg2, flags);\n","handlingStrategy":"type-guard","validationCode":"if (!(arg1 instanceof SUTime.Time)) { throw new IllegalArgumentException(\"PREV_IMMEDIATE requires arg1 to be a Time\"); }","typeGuard":"boolean canApplyPrevImmediate(SUTime.Temporal arg1) { return arg1 instanceof SUTime.Time; }","tryCatchPattern":"try { result = TemporalOp.PREV_IMMEDIATE.apply(arg1, arg2, flags); } catch (UnsupportedOperationException e) { /* convert arg1 via getRange().end() and retry */ }","preventionTips":["Ensure reference times parse as Time for 'this past X' phrases","Add instanceof checks around TemporalOp dispatch","Keep rule tests covering immediate past expressions"],"tags":["java","unsupported-operation","sutime","temporal"],"backgroundTag":"unsupported-operation","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"}