Skip to content

Commit c3ced32

Browse files
don't rollback parser state on constructor name binding error
1 parent 29dd8cb commit c3ced32

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

parser-typechecker/src/Unison/Syntax/TermParser.hs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module Unison.Syntax.TermParser
1414
where
1515

1616
import Control.Comonad.Trans.Cofree (CofreeF ((:<)))
17-
import Control.Lens (_2)
17+
import Control.Lens (mapped, _2)
1818
import Control.Monad.Reader (asks, local)
1919
import Control.Monad.Trans.Writer
2020
import Data.Bitraversable (bitraverse)
@@ -1365,11 +1365,8 @@ destructuringBind = do
13651365
-- (Some 42)
13661366
-- vs
13671367
-- (Some 42) = List.head elems
1368-
(p, boundVars) <- P.try do
1369-
(p, boundVars) <- parsePattern
1370-
let boundVars' = snd <$> boundVars
1371-
_ <- P.lookAhead (openBlockWith "=")
1372-
pure (p, boundVars')
1368+
pat <- P.try (parsePattern2 <* P.lookAhead (openBlockWith "="))
1369+
(p, boundVars) <- over (_2 . mapped) snd <$> bindConstructorsInPattern pat
13731370
(_spanAnn, scrute) <- layoutBlock "=" -- Dwight K. Scrute ("The People's Scrutinee")
13741371
let guard = Nothing
13751372
let absChain vs t = foldr (\v t -> ABT.abs' (ann t) v t) t vs

0 commit comments

Comments
 (0)