[ fix ] Totality checker misses indirect references to negative data #3043
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Idris reports a function as total when it indirectly references a negative data type, resulting in a proof of
Void
. This issue is reported in #527 and #3030. For direct references, the code inReferences.idr
detects the call, but it cuts when it hits anUnchecked
.The totality checking would detect the issue, but data constructor calls are not included in
sizeChange
list (they do show up inrefersTo
). I believe this is an oversight, but I may be missing something. My reasoning should be double-checked by someone who knows the totality checker.This PR changes
findSC
inCallGraph.idr
to includeDCon
applications in the sizechange graph. I've done this in theTopLevel
andGuarded
cases. I've also adjusted test cases to reflect the addition entries in size change, and I updated one test to reflect additional partial functions that are detected. I addedcovering
toREPL/Opts.idr
in two places because it refers to a negative data type.It fixes #527, fixes #3030, and is likely to break code that relies on faulty totalily results.
I have an alternative approach in a different branch, where I recursively call
calcTermination
on each reference of the function at the end ofcalcTermination
. If my assumptions are correct, I believe the present solution is cleaner and provides better error messages - showing the path that fails.As an example of the issue from the discussion at #3030, this proof of
Void
is accepted by Idris:implementation, I have updated
CHANGELOG.md
(and potentially alsoCONTRIBUTORS.md
).