unison/unison-src/tests/fix1640.u
Paul Chiusano fae001df80 Fix #1640 and also fix unreported pattern parsing bug and add test for it
Issue was actually in the parser. A pattern like `Foo Bar a b c` was being parsed as `Foo (Bar a b c)`. The pattern parser just needed to be factored a bit differently to fix.
2020-07-29 10:15:06 -04:00

26 lines
598 B
Plaintext

unique type Color = Red | Black
unique type RBTree a = Leaf | Tree Color (RBTree a) a (RBTree a)
-- interesting, this typechecks fine
isRed = cases
Color.Red -> true
Color.Black -> false
-- as does this
RBTree.isRed1 = cases
RBTree.Tree _ _ _ _ -> true
_ -> false
-- but this did not (before this fix)
RBTree.isRed = cases
RBTree.Tree Color.Red _ _ _ -> true
_ -> false
-- In fixing this bug, I noticed that the parser would previously reject
-- this perfectly cromulent pattern match, so I fixed that too.
thisIsTotallyLegit = cases
[RBTree.Tree _ _ _ _] -> true
_ -> false