This PR adds a warning to any `def` of class type that does not also declare an appropriate reducibility. The warning check runs after elaboration (checking the actual reducibility status via `getReducibilityStatus`) rather than syntactically checking modifiers before elaboration. This is necessary to accommodate patterns like `@[to_additive (attr := implicit_reducible)]` in Mathlib, where the reducibility attribute is applied during `.afterCompilation` by another attribute, and would be missed by a purely syntactic check. --------- Co-authored-by: Paul Reichert <6992158+datokrat@users.noreply.github.com> Co-authored-by: Kim Morrison <kim@tqft.net> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
23 lines
642 B
Text
23 lines
642 B
Text
import Lean.Hygiene
|
||
|
||
set_option warn.classDefReducibility false
|
||
|
||
def otherInhabited : Inhabited Nat := ⟨42⟩
|
||
|
||
def f := Id.run do
|
||
let ⟨n⟩ ← pure otherInhabited
|
||
-- do-notation expands to `pure otherInhabited >>= fun x : Inhabited Nat => ...`
|
||
-- the `x : Inhabited Nat` should not be available for TC synth (i.e., `default` should be 0)
|
||
return default + n
|
||
|
||
example : f = 42 := rfl
|
||
|
||
open Lean
|
||
def g : Syntax :=
|
||
let rec stx : Syntax := Unhygienic.run `(f 0 1)
|
||
let stx := stx
|
||
match stx with
|
||
| `(f $_args*) => ‹Syntax› -- should not resolve to tmp var created by stx matcher
|
||
| _ => default
|
||
|
||
example : g = g.stx := rfl
|