You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mark definitions in a noncomputable section that fail to compile with noncomputable attribute #9021
Currently, definitions in a noncomputable section that fail to compile do not get marked with noncomputable. The current check for noncomputable in the toMono pass checks for the attribute, but there is a second check in the IR phase for definitions without any IR. This still catches most issues, but it is possible for the use of a noncomputable definition to be erroneously optimized away between these two checks.
diff --git a/src/Lean/CoreM.lean b/src/Lean/CoreM.lean
index a89aeeadd6..880a90873f 100644
--- a/src/Lean/CoreM.lean
+++ b/src/Lean/CoreM.lean
@@ -9,6 +9,7 @@ import Lean.Util.Trace
import Lean.Log
import Lean.ResolveName
import Lean.Elab.InfoTree.Types
+import Lean.Compiler.NoncomputableAttr
import Lean.MonadEnv
import Lean.Elab.Exception
import Lean.Language.Basic
@@ -714,6 +715,9 @@ where doCompile := do
state.restore
if logErrors then
throw e
+ else
+ for decl in decls do
+ modifyEnv (addNoncomputable · decl)
def compileDecl (decl : Declaration) (logErrors := true) : CoreM Unit := do
compileDecls (Compiler.getDeclNamesForCodeGen decl) logErrors
However, it has two problems:
Setting an attribute in this async context doesn't work right. I'll have to sort this out with Sebastian, as some of the code wrapping the compiler is related to the way that the old compiler used the kernel environment.
if I force non-async elaboration, then there are new noncomputable failures in Mathlib. A number of these are fixed by fix: mark irrelevant params as erased in mono type signatures #9226, which we want for other reasons, but it has a bizarre memory usage regression that needs to be investigated.
Activity
zwarich commentedon Jul 11, 2025
The basic idea of this fix is simple:
However, it has two problems:
noncomputablefailures in Mathlib. A number of these are fixed by fix: mark irrelevant params as erased in mono type signatures #9226, which we want for other reasons, but it has a bizarre memory usage regression that needs to be investigated.