{"record":{"id":"996c36f22203d0c9","repo":"stanfordnlp/CoreNLP","slug":"prev-not-implemented-for-arg1-arg1-getclass","errorCode":null,"errorMessage":"PREV not implemented for arg1=${arg1.getClass()}, arg2=${arg2.getClass()}","messagePattern":"PREV not implemented for arg1=(.+?), arg2=(.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/time/SUTime.java","lineNumber":1090,"sourceCode":"      }\n    },\n    // (predecessor) Previous week/day/...\n    PREV {\n      @Override\n      public Temporal apply(Temporal arg1, Temporal arg2, int flags) {\n        if (arg2 == null) {\n          return arg1;\n        }\n        Temporal arg2Prev = arg2.prev();\n        if (arg1 == null || arg2Prev == null) {\n          return arg2Prev;\n        }\n        if (arg1 instanceof Time) {\n          // TODO: flags?\n          Temporal resolved = arg2Prev.resolve((Time) arg1, 0 /*RESOLVE_TO_PAST */);\n          return resolved;\n        } else {\n          throw new UnsupportedOperationException(\"PREV not implemented for arg1=\" + arg1.getClass() + \", arg2=\" + arg2.getClass());\n        }\n      }\n    },\n    // This past week/friday\n    PREV_IMMEDIATE {\n      @Override\n      public Temporal apply(Temporal arg1, Temporal arg2, int flags) {\n        if (arg1 == null) {\n          return new RelativeTime(PREV_IMMEDIATE, arg2);\n        }\n        if (arg2 == null) {\n          return arg1;\n        }\n        // Temporal arg2Prev = arg2.prev();\n        // if (arg1 == null || arg2Prev == null) { return arg2Prev; }\n        if (arg1 instanceof Time) {\n          Time t = (Time) arg1;\n          if (arg2 instanceof Duration) {","sourceCodeStart":1072,"sourceCodeEnd":1108,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/time/SUTime.java#L1072-L1108","documentation":"TemporalOp.PREV ('last week', 'previous Monday') resolves arg2 backwards using arg1 as a Time reference. If arg1 is not a Time, the backward resolution is undefined and the operator throws UnsupportedOperationException stating the two argument classes.","triggerScenarios":"Calling SUTime.TemporalOp.PREV.apply(arg1, arg2, flags) with arg1 being a Duration, Range, or other non-Time Temporal, typically from custom TokensRegex temporal rules.","commonSituations":"Parsing 'last year'/'previous month' style phrases where the anchoring time expression was not recognized; programmatic misuse of the TemporalOp API.","solutions":["Pass a SUTime.Time as arg1 — resolve the reference temporal to a Time first","Read the exception message's class names and fix the rule or call site that produced them","Add an instanceof Time guard with an explicit fallback","Report a CoreNLP bug if a shipped rule hits this"],"exampleFix":"// before\nTemporalOp.PREV.apply(arg1, arg2, 0);\n// after\nif (arg1 instanceof Time) {\n  TemporalOp.PREV.apply(arg1, arg2, 0);\n} else {\n  TemporalOp.PREV.apply(arg1.getRange().begin(), arg2, 0);\n}\n","handlingStrategy":"type-guard","validationCode":"if (!(arg1 instanceof SUTime.Time)) { throw new IllegalArgumentException(\"PREV requires arg1 to be a Time\"); }","typeGuard":"boolean canApplyPrev(SUTime.Temporal arg1) { return arg1 instanceof SUTime.Time; }","tryCatchPattern":"try { result = TemporalOp.PREV.apply(arg1, arg2, flags); } catch (UnsupportedOperationException e) { /* resolve arg1 to a Time and retry */ }","preventionTips":["Anchor PREV with a Time reference","Validate rule output types before operator application","Test 'last/previous X' phrase parsing"],"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"}