w3c / qt3tests

Tests for XPath and XQuery
27 stars 17 forks source link

fn:matches surprisingly returns false for `fn:matches("AB", "^(.*)+B")` #59

Open faassen opened 5 months ago

faassen commented 5 months ago

With Saxon, fn:matches("AB", "^(.*)+B") returns false, and I don't understand why. I've ported Saxon's regex engine to Rust, and I'm also getting a false here (once I fixed another bug), which surprised me, so I verified that Saxon does the same.

Looking at it, the .* should consume "A", and then "B" should be matched. But it doesn't do that.

On regex101 all the flavors have it match https://regex101.com/r/JfmqWf/1

I'm trying to understand why it wouldn't match for the XPath regex flavor. And whether it should match or not, I think it's worthwhile adding a test case to the test suite to nail this behavior down.

This behavior is implemented inside of the Repeat op, for greedy matching. I suspect it's in advance() (in the Java code). I see a bug was fixed previously (3787).

michaelhkay commented 5 months ago

We can certainly look at this as a Saxon issue.

For clarity, though, you have raised this as an issue against the W3C test suite. Is there a test in the test suite that you believe to be incorrect?

michaelhkay commented 5 months ago

I've logged a Saxon bug at https://saxonica.plan.io/issues/6426 -- please follow progress there.

faassen commented 5 months ago

I think a new test should be added to the test suite, so it's good to track this here too.

faassen commented 5 months ago

I'd like to see what fix you applied in Saxon so I can port it to my Rust version, but I think I have to wait for an open source release to see what you changed, correct?