Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Lean/Meta/Diagnostics.lean
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ def appendSection (m : Array MessageData) (cls : Name) (header : String) (s : Di
/-- Logs diagnostics and resets the counters -/
def reportDiag : MetaM Unit := do
if (← isDiagnosticsEnabled) then
-- Diagnostic output may reference private declarations (e.g. `_match_*`,
-- `_sparseCasesOn_*`) that are not visible in exporting mode (issue #13581).
withoutExporting do
let unfoldCounter := (← get).diag.unfoldCounter
let unfoldDefault ← mkDiagSummaryForUnfolded unfoldCounter
let unfoldInstance ← mkDiagSummaryForUnfolded unfoldCounter (instances := true)
Expand Down
3 changes: 3 additions & 0 deletions src/Lean/Meta/Tactic/Simp/Diagnostics.lean
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ def mkDiagMessages (diag : Simp.Diagnostics) : MetaM (Array MessageData) := do

def reportDiag (diag : Simp.Diagnostics) : MetaM Unit := do
if (← isDiagnosticsEnabled) then
-- Diagnostic output may reference private declarations that are not visible
-- in exporting mode (issue #13581).
withoutExporting do
let m ← mkDiagMessages diag
unless m.isEmpty do
logInfo <| .trace { cls := `simp, collapsed := false } "Diagnostics" m
Expand Down
15 changes: 15 additions & 0 deletions tests/elab/13581.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- https://github.com/leanprover/lean4/issues/13581
-- Reporting `diagnostics` must not crash on private match/sparseCasesOn helpers
-- in module mode under a `public section`.
module

public section

def onlyTrue : Bool → Bool
| true => true
| x => x

#guard_msgs (drop trace) in
set_option diagnostics true in
set_option diagnostics.threshold 0 in
example : onlyTrue true = true := rfl
Loading