Skip to content

Commit

Permalink
fix: hasBadParamDep? to look at term, not type
Browse files Browse the repository at this point in the history
fixes #4671
  • Loading branch information
nomeata committed Jul 6, 2024
1 parent 5ad5c2c commit 4272002
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/Lean/Elab/PreDefinition/Structural/FindRecArg.lean
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ private def hasBadIndexDep? (ys : Array Expr) (indices : Array Expr) : MetaM (Op
-- Inductive datatype parameters cannot depend on ys
private def hasBadParamDep? (ys : Array Expr) (indParams : Array Expr) : MetaM (Option (Expr × Expr)) := do
for p in indParams do
let pType ← inferType p
for y in ys do
if ← dependsOn pType y.fvarId! then
if ← dependsOn p y.fvarId! then
return some (p, y)
return none

Expand Down
20 changes: 20 additions & 0 deletions tests/lean/run/issue4671.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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 parameter
n
depends on
n
-/
#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

0 comments on commit 4272002

Please sign in to comment.