fix: ignore unused alternatives in Ord derive handler (#3725)
Closes #3706
This derive handler's implementation is very similar to `BEq`'s, which
already ignores unused alternative so as to work correctly on indexed
inductive types. This PR simply implements the same solution as the one
present in
[`BEq.lean`](2c15cdda04/src/Lean/Elab/Deriving/BEq.lean (L94)).
After some tests, it doesn't seem like any other derive handler present
in Core suffers from the same issue (though some handlers don't work on
indexed inductives for other reasons).
This commit is contained in:
parent
4d4e467392
commit
bf8b66c6a5
2 changed files with 14 additions and 0 deletions
|
|
@ -84,6 +84,7 @@ def mkMutualBlock (ctx : Context) : TermElabM Syntax := do
|
|||
for i in [:ctx.typeInfos.size] do
|
||||
auxDefs := auxDefs.push (← mkAuxFunction ctx i)
|
||||
`(mutual
|
||||
set_option match.ignoreUnusedAlts true
|
||||
$auxDefs:command*
|
||||
end)
|
||||
|
||||
|
|
|
|||
13
tests/lean/run/3706.lean
Normal file
13
tests/lean/run/3706.lean
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/--Ensure that `deriving Ord` works on indexed inductive types.-/
|
||||
inductive Ty where
|
||||
| int
|
||||
| bool
|
||||
inductive Expr : Ty → Type where
|
||||
| a : Expr .int
|
||||
| b : Expr .bool
|
||||
deriving Ord
|
||||
|
||||
inductive Vec (α : Type u) : Nat → Type u
|
||||
| nil : Vec α 0
|
||||
| cons : α → {n : Nat} → Vec α n → Vec α (n+1)
|
||||
deriving Ord
|
||||
Loading…
Add table
Reference in a new issue