{"record":{"id":"a42b197232566cb6","repo":"oracle/graal","slug":"got-non-equal-toindex-d-and-regionto-d-supp","errorCode":null,"errorMessage":"got non-equal toIndex (%d) and regionTo (%d), support for this is not implemented yet","messagePattern":"got non-equal toIndex \\((.+?)\\) and regionTo \\((.+?)\\), support for this is not implemented yet","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/RegexExecNode.java","lineNumber":102,"sourceCode":"                CompilerDirectives.transferToInterpreterAndInvalidate();\n                throw new IllegalArgumentException(String.format(\"got illegal regionFrom value: %d. regionFrom must be >= 0 and <= input length (%d)\", regionFromLong, length));\n            }\n            if (regionToLong < regionFromLong || regionToLong > length) {\n                CompilerDirectives.transferToInterpreterAndInvalidate();\n                throw new IllegalArgumentException(String.format(\"got illegal regionTo value: %d. regionTo must be >= regionFrom (%d) and <= input length (%d)\", regionToLong, regionFromLong, length));\n            }\n            if (fromIndex < regionFromLong || fromIndex > regionToLong) {\n                CompilerDirectives.transferToInterpreterAndInvalidate();\n                throw new IllegalArgumentException(\n                                String.format(\"got illegal fromIndex value: %d. fromIndex must be >= regionFrom (%d) and <= regionTo (%d)\", fromIndex, regionFromLong, regionToLong));\n            }\n            if (toIndexLong < fromIndex || toIndexLong > regionToLong) {\n                CompilerDirectives.transferToInterpreterAndInvalidate();\n                throw new IllegalArgumentException(String.format(\"got illegal toIndex value: %d. toIndex must be >= fromIndex (%d) and <= regionTo (%d)\", toIndexLong, fromIndex, regionToLong));\n            }\n            if (toIndexLong != regionToLong) {\n                CompilerDirectives.transferToInterpreterAndInvalidate();\n                throw new UnsupportedOperationException(String.format(\"got non-equal toIndex (%d) and regionTo (%d), support for this is not implemented yet\", toIndexLong, regionToLong));\n            }\n            toIndex = (int) toIndexLong;\n            regionFrom = (int) regionFromLong;\n            regionTo = (int) regionToLong;\n        } else {\n            assert args.length == 2;\n            toIndex = length;\n            regionFrom = 0;\n            regionTo = length;\n            if (fromIndex < 0 || fromIndex > length) {\n                CompilerDirectives.transferToInterpreterAndInvalidate();\n                throw new IllegalArgumentException(String.format(\"got illegal fromIndex value: %d. fromIndex must be >= 0 and <= input length (%d)\", fromIndex, length));\n            }\n        }\n        return execute(frame, input, adjustFromIndex(input, (int) fromIndex, regionFrom, regionTo), toIndex, regionFrom, regionTo);\n    }\n\n    private int adjustFromIndex(TruffleString input, int fromIndex, int regionFrom, int regionTo) {","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/RegexExecNode.java#L84-L120","documentation":"The 5-argument form of RegexExecNode currently only implements toIndex == regionTo. Passing a toIndex different from regionTo (even if otherwise in range) throws UnsupportedOperationException, signaling an engine limitation rather than invalid arguments.","triggerScenarios":"Calling 5-arg exec where toIndexLong != regionToLong, e.g. trying to search only a prefix of the region (toIndex < regionTo) as Java's Matcher.region(from, to).find() with an additional end bound would.","commonSituations":"Porting code that assumes java.util.regex-style independent search-window and region bounds onto the Truffle regex engine; polyglot adapters exposing a richer region API than TRegex supports.","solutions":["Pass toIndex equal to regionTo and enforce any tighter search end by shrinking regionTo.","If you truly need an independent search window, fall back to host java.util.regex for that call.","Track the TRegex repository for the 'non-equal toIndex/regionTo' support landing before exposing such an API."],"exampleFix":"// before\nexec(input, from, searchEnd, regionFrom, regionEnd); // searchEnd != regionEnd -> UnsupportedOperationException\n\n// after\nexec(input, from, regionEnd, regionFrom, regionEnd); // use regionEnd as toIndex; narrow regionFrom..searchEnd if needed","handlingStrategy":"fallback","validationCode":"static boolean engineSupportsSearchWindow(long toIndex, long regionTo) {\n    return toIndex == regionTo; // TRegex 5-arg exec only implements toIndex == regionTo\n}","typeGuard":null,"tryCatchPattern":"if (toIndex != regionTo) {\n    // engine limitation: fall back to host java.util.regex for this call\n    return hostRegexSearch(input, fromIndex, toIndex, regionFrom, regionTo);\n}\nreturn exec(input, fromIndex, regionTo, regionFrom, regionTo);","preventionTips":["Do not expose an independent search-window end bound in APIs backed by TRegex.","Express narrower searches by shrinking regionTo instead.","Watch TRegex release notes for 'non-equal toIndex and regionTo' support."],"tags":["regex","truffle","graalvm","unsupported-operation","region"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}