-
Notifications
You must be signed in to change notification settings - Fork 379
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
[ fix #3437 ] Add a check for multiple totality modifiers #3441
base: main
Are you sure you want to change the base?
Conversation
Would be nice if the message could explain why that's a problem and how to fix it. something like "Multiple incompatible totality modifier were given for this function." And give multiple ways to solve it. Either by relying on the default totality or by overriding the default. |
I think any use of multiple totality modifiers (including identical ones) on a single declaration should be an error. The default totality no matter. |
This is incorrect. %default total
covering
main : IO ()
main = … is a common pattern. In the case of multiple definitions, like |
I mean, the presence of |
Alright I'll do it myself |
Regardless of the goals of this PR, I’d add that in my opinion it’s ok to have e.g. a That is, in my opinion the only thing that should be an error is if there are multiple totalities defined explicitly on the function. |
Let's get this in and someone else will implement #3442 |
Okay, I understand the errors you suggest. I'll add them |
I have tried to make correct error messages that take into account the presence of all totality modifiers. This commit does not affect the ability to override totality in Data |
I'm sorry if my messages might have come across as rude. I don't always know the best way to express my thoughts in English |
I think your messages are coming across just fine (no rude tone detected by me, at least). |
= let opts = maybe opts_in (\t => Totality t :: opts_in) treq in | ||
IClaim (MkFCVal vfc (MkIClaimData c vis opts (MkImpTy EmptyFC (NoFC n) mty))) | ||
= do let opts = if isJust $ findTotality opts_in | ||
then opts_in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this throwing away the explicit totality passed to this function quietly? Seems like that could result in surprising behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
treq
is a totality from a function declaration in the interface. If the implementation contains its own totality modifier, it is overrided. Previously both flags were left, but this is not useful. See #3437 (comment)
Description
processFnOpt
.elabImplementation
does not add a totality modifier from the interface if it is overridden in the implementation. This is to prevent multiple modifiers from appearing after desugaring.Checking when desugaring is enough for Idris, but I left the changes to
processFnOpt
as they also check TTImp.Should this change go in the CHANGELOG?
implementation, I have updated
CHANGELOG_NEXT.md
(and potentially alsoCONTRIBUTORS.md
).