-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make
elab_as_elim
eagerly elaborate arguments for parameters a…
…ppearing in the types of targets (#4800) The `elab_as_elim` elaborator eagerly elaborates arguments that can help with elaborating the motive, however it does not include the transitive closure of parameters appearing in types of parameters appearing in ... types of targets. This leads to counter-intuitive behavior where arguments supplied to the eliminator may unexpectedly have postponed elaboration, causing motives to be type incorrect for under-applied eliminators such as the following: ```lean class IsEmpty (α : Sort u) : Prop where protected false : α → False @[elab_as_elim] def isEmptyElim [IsEmpty α] {p : α → Sort _} (a : α) : p a := (IsEmpty.false a).elim example {α : Type _} [IsEmpty α] : id (α → False) := isEmptyElim (α := α) ``` The issue is that when `isEmptyElim (α := α)` is computing its motive, the value of the postponed argument `α` is still an unassignable metavariable. With this PR, this argument is now among those that are eagerly elaborated since it appears as the type of the target `a`. This PR also contains some other fixes: * When underapplied, does unification when instantiating foralls in the expected type. * When overapplied, type checks the generalized-and-reverted expected type. * When collecting targets, collects them in the correct order. Adds trace class `trace.Elab.app.elab_as_elim`. This is a followup to #4722, which added motive type checking but exposed the eagerness issue.
- Loading branch information
Showing
4 changed files
with
243 additions
and
134 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.