Skip to content

Commit

Permalink
fix: add missing initHeartbeats
Browse files Browse the repository at this point in the history
In only one case a `Core.Context` is created from within CoreM, and we inherit from the parent Context the `initHeartbeats`. Otherwise, we get the current heartbeats from IO.

Co-authored-by: Laurent Sartran <[email protected]>
  • Loading branch information
eric-wieser and lsartran committed Nov 11, 2024
1 parent 1bfaec4 commit c753fca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Batteries/Tactic/Lint/Frontend.lean
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def lintCore (decls : Array Name) (linters : Array NamedLinter) :
CoreM (Array (NamedLinter × Std.HashMap Name MessageData)) := do
let env ← getEnv
let options ← getOptions -- TODO: sanitize options?
let initHeartbeats := (← read).initHeartbeats

let tasks : Array (NamedLinter × Array (Name × Task (Option MessageData))) ←
linters.mapM fun linter => do
Expand All @@ -108,7 +109,7 @@ def lintCore (decls : Array Name) (linters : Array NamedLinter) :
BaseIO.asTask do
match ← withCurrHeartbeats (linter.test decl)
|>.run' mkMetaContext
|>.run' {options, fileName := "", fileMap := default} {env}
|>.run' {options, fileName := "", fileMap := default, initHeartbeats } {env}
|>.toBaseIO with
| Except.ok msg? => pure msg?
| Except.error err => pure m!"LINTER FAILED:\n{err.toMessageData}"
Expand Down
3 changes: 2 additions & 1 deletion Batteries/Util/Cache.lean
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ def Cache.get [Monad m] [MonadEnv m] [MonadLog m] [MonadOptions m] [MonadLiftT B
-- TODO: add customization option
let options := maxHeartbeats.set options <|
options.get? maxHeartbeats.name |>.getD 1000000
let initHeartbeats ← IO.getNumHeartbeats
let res ← EIO.asTask <|
init {} |>.run' {} { options, fileName, fileMap } |>.run' { env }
init {} |>.run' {} { options, fileName, fileMap, initHeartbeats } |>.run' { env }
cache.set (m := BaseIO) (.inr res)
pure res
match t.get with
Expand Down

0 comments on commit c753fca

Please sign in to comment.