refactor: split noncomputable error into its own helper (#9314)

This commit is contained in:
Cameron Zwarich 2025-07-11 10:30:22 -07:00 committed by GitHub
parent d4e11f754a
commit e2e36087e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -23,9 +23,12 @@ def Param.toMono (param : Param) : ToMonoM Param := do
modify fun s => { s with typeParams := s.typeParams.insert param.fvarId }
param.update (← toMonoType param.type)
def throwNoncomputableError {α : Type} (declName : Name) : ToMonoM α :=
throwNamedError lean.dependsOnNoncomputable m!"failed to compile definition, consider marking it as 'noncomputable' because it depends on '{.ofConstName declName}', which is 'noncomputable'"
def checkFVarUse (fvarId : FVarId) : ToMonoM Unit := do
if let some declName := (← get).noncomputableVars.get? fvarId then
throwNamedError lean.dependsOnNoncomputable m!"failed to compile definition, consider marking it as 'noncomputable' because it depends on '{.ofConstName declName}', which is 'noncomputable'"
throwNoncomputableError declName
def checkFVarUseDeferred (resultFVar fvarId : FVarId) : ToMonoM Unit := do
if let some declName := (← get).noncomputableVars.get? fvarId then