Merge pull request #4790 from unisonweb/fix/pattern-many

Fix many pattern not backtracking
This commit is contained in:
Arya Irani 2024-03-18 21:12:15 -06:00 committed by GitHub
commit 48f5a30854
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 40 additions and 1 deletions

View File

@ -157,7 +157,7 @@ compile (Many p) !_ !success = case p of
Char cp -> walker (charPatternPred cp)
p -> go
where
go = compile p success success'
go = try "Many" (compile p) success success'
success' acc rem
| Text.size rem == 0 = success acc rem
| otherwise = go acc rem

View File

@ -0,0 +1,11 @@
```ucm:hide
.> builtins.merge
```
Some tests of pattern behavior.
```unison
p1 = join [literal "blue", literal "frog"]
> Pattern.run (many p1) "bluefrogbluegoat"
```

View File

@ -0,0 +1,28 @@
Some tests of pattern behavior.
```unison
p1 = join [literal "blue", literal "frog"]
> Pattern.run (many p1) "bluefrogbluegoat"
```
```ucm
Loading changes detected in scratch.u.
I found and typechecked these definitions in scratch.u. If you
do an `add` or `update`, here's how your codebase would
change:
⍟ These new definitions are ok to `add`:
p1 : Pattern Text
Now evaluating any watch expressions (lines starting with
`>`)... Ctrl+C cancels.
3 | > Pattern.run (many p1) "bluefrogbluegoat"
Some ([], "bluegoat")
```