Skip to content

Conversation

@dunhamsteve
Copy link
Collaborator

Description

There are a few cases where the "With clause does not match parent" error points to the parent LHS instead of the with application containing the error. The second code snippet in #3317 illustrates one case, where a parenthesis mismatch caused a function application to be interpreted as the first argument. Additional cases are for IAlternative and IPrimVal. I've included a test case for each.

The example from #3317:

f :  Eq a => (xs : List a) -> { auto p : NonEmpty xs } -> Nat
f (x::xs) with (sizeAccessible xs)
  f [_] | _ = 1
  f (x::y::zs) | Access r =
    if x /= y
       then f (x::zs) | r _ reflexive
       else S (f (x::zs)) | r _ reflexive

Idris currently says:

 Error: With clause does not match parent

WithMatch:11:4--11:9
 10 | f :  Eq a => (xs : List a) -> { auto p : NonEmpty xs } -> Nat
 11 | f (x::xs) with (sizeAccessible xs)
         ^^^^^

and with this change, we get:

Error: With clause does not match parent

WithMatch:16:16--16:17
 12 |   f [_] | _ = 1
 13 |   f (x::y::zs) | Access r =
 14 |     if x /= y
 15 |        then f (x::zs) | r _ reflexive
 16 |        else S (f (x::zs)) | r _ reflexive
                     ^

I've named the test case idris2/error/withMatches rather than idris2/error/error034 as the latter would conflict with another PR. Let me know if this is an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants