Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ error ] Improve error messages for Delay &co #3037

Merged
merged 1 commit into from
Aug 4, 2023

Conversation

dunhamsteve
Copy link
Contributor

Description

This PR improves error messages in Delay statements to address #3036. It adds a check for an additional simpleExpr after the statement. It also introduces a mustFailBecause helper function that will fail with a message if a given parser succeeds at the current point.

Prior to this change, the following code:

module DelayParse

public export
data MyStream : Type where
  (::) :  (anA : a)
       -> (nextA : a -> a)
       -> Inf MyStream
       -> MyStream

public export
go : a -> (a -> a) -> MyStream
go initA fn =
  MyStream.(::) initA fn (Delay (fn initA) fn)

would fail with:

1/1: Building tests.idris2.perror029.DelayParse (tests/idris2/perror029/DelayParse.idr)
Error: Not the end of a block entry, check indentation.

tests.idris2.perror029.DelayParse:13:26--13:27
 09 |
 10 | public export
 11 | go : a -> (a -> a) -> MyStream
 12 | go initA fn =
 13 |   MyStream.(::) initA fn (Delay (fn initA) fn)
                               ^

and now we get:

1/1: Building DelayParse (DelayParse.idr)
Error: Delay only takes one argument.

DelayParse:13:44--13:46
 09 | 
 10 | public export
 11 | go : a -> (a -> a) -> MyStream
 12 | go initA fn =
 13 |   MyStream.(::) initA fn (Delay (fn initA) fn)
                                                 ^^

@gallais
Copy link
Member

gallais commented Aug 4, 2023

Sorry about the missclick. I wanted to say that I suspected this PR
would arrive when I mentioned the fact the parser was the problem. :)

@gallais gallais merged commit f0f776c into idris-lang:main Aug 4, 2023
25 checks passed
@dunhamsteve dunhamsteve deleted the issue-3036 branch August 4, 2023 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misapplication of Delay causes indentation error instead of type mismatch
3 participants