Skip to content

Commit 95583d7

Browse files
leodemourakim-em
authored andcommitted
fix: normalize instance argument in getStuckMVar? for class projections (#12778)
This PR fixes an inconsistency in `getStuckMVar?` where the instance argument to class projection functions and auxiliary parent projections was not whnf-normalized before checking for stuck metavariables. Every other case in `getStuckMVar?` (recursors, quotient recursors, `.proj` nodes) normalizes the major argument via `whnf` before recursing — class projection functions and aux parent projections were the exception. This bug was identified by Matthew Jasper. When the instance parameter to a class projection is not normalized, `getStuckMVar?` may fail to detect stuck metavariables that would be revealed by whnf, or conversely may report stuckness for expressions that would reduce to constructors. This caused issues with `OfNat` and `Zero` at `with_reducible_and_instances` transparency. Note: PR #12701 (already merged) is also required to fix the original Mathlib examples.
1 parent b9bfacd commit 95583d7

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/Lean/Meta/WHNF.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ mutual
348348
unless projInfo.fromClass do return none
349349
-- First check whether `e`s instance is stuck.
350350
if let some major := args[projInfo.numParams]? then
351-
if let some mvarId ← getStuckMVar? major then
351+
if let some mvarId ← getStuckMVar? (← whnf major) then
352352
return mvarId
353353
/-
354354
Then, recurse on the explicit arguments
@@ -366,7 +366,7 @@ mutual
366366
else if let some auxInfo ← getAuxParentProjectionInfo? fName then
367367
unless auxInfo.fromClass do return none
368368
if let some major := args[auxInfo.numParams]? then
369-
if let some mvarId ← getStuckMVar? major then
369+
if let some mvarId ← getStuckMVar? (← whnf major) then
370370
return mvarId
371371
return none
372372
else

0 commit comments

Comments
 (0)