rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

Js.Re.matches -> RegExp.Result.matches - Unexpected bug caused by migration to v12

Open DZakh opened this issue 1 month ago • 5 comments

https://rescript-lang.org/try?version=v12.0.0-rc.3&module=esmodule&code=DYUwLgBAhhC8EFIBOUDuAKABgbQLqYEoBaAPgCkBnAOgCUQqBbKMAYwAsQKAoL0SAIziIUGHPmIk6AcwCiADwAOtTgFdgYRs3acgA

The automated migration results in a different output, which was very difficult to trace in my case. I spent around 4 hours today (mostly because the issue wasn't reproducing locally)

DZakh avatar Nov 21 '25 12:11 DZakh

Could you have a look at the migration and see what the solution might be? What is it doing wrong?

zth avatar Nov 21 '25 12:11 zth

I think the migration logic is correct; it's just different logic now, which fixes the previous incorrect behaviour.

DZakh avatar Nov 21 '25 14:11 DZakh

I don't understand. What's the problem here if the migration is not wrong?

zth avatar Nov 21 '25 18:11 zth

Look at the generated code. It produces different output, which leads to different runtime behaviour.

DZakh avatar Nov 23 '25 12:11 DZakh

Then I would say that the migration isn't correct, or even can't be done, if the APIs are not equivalent. What do you think?

zth avatar Nov 24 '25 08:11 zth