fix: revert state on compilation failure (new compiler) (#8691)
This PR ensures that the state is reverted when compilation using the new compiler fails. This is especially important for noncomputable sections where the compiler might generate half-compiled functions which may then be erroneously used while compiling other functions.
This commit is contained in:
parent
4a539715c8
commit
e6954b7837
1 changed files with 8 additions and 3 deletions
|
|
@ -718,9 +718,14 @@ where doCompile := do
|
|||
return
|
||||
let opts ← getOptions
|
||||
if compiler.enableNew.get opts then
|
||||
withoutExporting
|
||||
try compileDeclsNew decls catch e =>
|
||||
if logErrors then throw e else return ()
|
||||
withoutExporting do
|
||||
let state ← Core.saveState
|
||||
try
|
||||
compileDeclsNew decls
|
||||
catch e =>
|
||||
state.restore
|
||||
if logErrors then
|
||||
throw e
|
||||
else
|
||||
let res ← withTraceNode `compiler (fun _ => return m!"compiling old: {decls}") do
|
||||
return compileDeclsOld (← getEnv) opts decls
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue