morganstanley / hobbes

A language and an embedded JIT compiler
http://hobbes.readthedocs.io/
Apache License 2.0
1.16k stars 105 forks source link

match with regex doesn't set variable correctly when backtracking. #367

Open adam-antonik opened 4 years ago

adam-antonik commented 4 years ago

Changing the example from the from the front-page slightly to match "f(o*)obar"

match "foobar" with
| 'f(?<os>o*)obar' -> os
| _               -> "???"

will evaluate to "oo", not "o". Similarly, if we use 'f(?.*)bar', then os = "oobar".

kthielen commented 4 years ago

Good catch, I will take a look.

kthielen commented 3 years ago

Sorry adam, lots going on, I'm no longer part of the project or Morgan Stanley, can't submit a change anymore. I might be able to get a fix into my fork but have some other issues to take care of first.