-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:
hasBadParamDep?
to look at term, not type (#4672)
The previous check, looking only at the type of the parameter, was too permissive and led to ill-typed terms later on. This fixes #4671. In some cases the previous code might have worked by accident, in this sense this is a breaking change. Affected functions can be fixed by reordering their parameters to that all the function parameters that occur in the parameter of the inductive type of the parameter that the function recurses on come first.
- Loading branch information
Showing
2 changed files
with
23 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
set_option linter.constructorNameAsVariable false | ||
|
||
inductive A (n : Nat) : Type | ||
| a : A n | ||
| b : A n → A n | ||
|
||
/-- | ||
error: argument #3 cannot be used for structural recursion | ||
its type is an inductive datatype | ||
A n | ||
and the datatype parameter | ||
n | ||
depends on the function parameter | ||
n | ||
which does not come before the varying parameters and before the indices of the recursion parameter. | ||
-/ | ||
#guard_msgs in | ||
def A.size (acc n : Nat) : A n → Nat | ||
| .a => acc | ||
| .b a' => 1 + A.size (acc + 1) n a' | ||
termination_by structural a => a |