Skip to content

regex.Matcher.lookingAt() and matches() incorrect in 1.3.0 #4252

@thesamet

Description

@thesamet

This is a regression in regex matcher() compared to 1.2.0:

val p = java.util.regex.Pattern.compile("a+")
val m = p.matcher("abaa").region(2,4);
println(m.lookingAt())
println(m.group())

In 1.2.0, the code would correctly print:

true
aa

In 1.3.0:

false
/tmp/sjs/target/scala-2.13/scala-js-tutorial-fastopt/main.js:1128
    throw new $c_jl_IllegalStateException("No match available")
    ^

java.lang.IllegalStateException: No match available
    at $p_ju_regex_Matcher__ensureLastMatch__sjs_js_RegExp$ExecResult (/tmp/sjs/target/scala-2.13/scala-js-tutorial-fastopt/main.js:1128:11)
    at $c_ju_regex_Matcher.group__T (/tmp/sjs/target/scala-2.13/scala-js-tutorial-fastopt/main.js:1201:19)
    at $c_Ltutorial_webapp_TutorialApp$.main__AT__V (/tmp/sjs/target/scala-2.13/scala-js-tutorial-fastopt/main.js:1030:19)
    at $s_Ltutorial_webapp_TutorialApp__main__AT__V (/tmp/sjs/target/scala-2.13/scala-js-tutorial-fastopt/main.js:1013:38)
    at /tmp/sjs/target/scala-2.13/scala-js-tutorial-fastopt/main.js:3244:1
    at /tmp/sjs/target/scala-2.13/scala-js-tutorial-fastopt/main.js:3245:4
    at Script.runInThisContext (vm.js:122:20)
    at Object.runInThisContext (vm.js:329:38)
    at [stdin]:8:25
    at Script.runInThisContext (vm.js:122:20)

This blocks upgrading ScalaPB to Scala.js 1.3.x.

Metadata

Metadata

Assignees

Labels

bugConfirmed bug. Needs to be fixed.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions