Fix bug with what value was propagated from rhs of alt parse failure and add test case for '@' as value constructor.

This commit is contained in:
Mathew Polzin 2021-07-14 00:25:02 -07:00
parent 385a61a364
commit 830e5dc12d
6 changed files with 42 additions and 14 deletions

View File

@ -317,8 +317,10 @@ doParse s com (Alt {c1} {c2} x y) xs
then Failure com fatal errs
else case (assert_total doParse s False y xs) of
(Failure com'' fatal' errs') => if com'' || fatal'
-- Only add the errors together if the second branch
-- is also non-committed and non-fatal.
then Failure com fatal' errs'
else Failure com'' fatal' (errs ++ errs')
else Failure com False (errs ++ errs')
(Res s _ val xs) => Res s com val xs
-- Successfully parsed the first option, so use the outer commit flag
Res s _ val xs => Res s com val xs

View File

@ -66,7 +66,7 @@ idrisTestsError = MkTestPool "Error messages" [] Nothing
"error016", "error017", "error018", "error019",
-- Parse errors
"perror001", "perror002", "perror003", "perror004", "perror005",
"perror006", "perror007", "perror008"]
"perror006", "perror007", "perror008", "perror009"]
idrisTestsInteractive : TestPool
idrisTestsInteractive = MkTestPool "Interactive editing" [] Nothing

View File

@ -0,0 +1,4 @@
data Foo : Type where
FooBase : Foo
(@) : Foo -> Foo -> Foo

View File

@ -0,0 +1,19 @@
1/1: Building Error1 (Error1.idr)
Error: Couldn't parse any alternatives:
1: Expected name.
Error1:4:3--4:4
1 |
2 | data Foo : Type where
3 | FooBase : Foo
4 | (@) : Foo -> Foo -> Foo
^
2: Can't use reserved symbol @.
Error1:4:4--4:5
1 |
2 | data Foo : Type where
3 | FooBase : Foo
4 | (@) : Foo -> Foo -> Foo
^

View File

@ -0,0 +1,3 @@
$1 --no-color --console-width 0 --no-banner -Werror --check Error1.idr
rm -rf build/

View File

@ -32,20 +32,20 @@ Mismatch between: Vect 0 ?elem and List ?a.
Main> the (Maybe Integer) (pure 4) : Maybe Integer
Main> Couldn't parse any alternatives:
1: Expected 'case', 'if', 'do', application or operator expression.
1: Expected namespaced name.
(Interactive):1:10--1:11
1 | :t with [] 4
^
2: Expected '('.
(Interactive):1:10--1:11
1 | :t with [] 4
^
3: Expected 'if'.
(Interactive):1:4--1:5
1 | :t with [] 4
^
2: Expected '`'.
(Interactive):1:4--1:5
1 | :t with [] 4
^
3: Expected operator.
(Interactive):1:4--1:5
1 | :t with [] 4
^
... (42 others)
... (8 others)
Main> Bye for now!