Skip to content

Commit

Permalink
fix: print prefix bug (#996)
Browse files Browse the repository at this point in the history
Co-authored-by: Mario Carneiro <di.gama@gmail.com>
  • Loading branch information
fgdorais and digama0 authored Oct 19, 2024
1 parent 6f56968 commit 1e0bf50
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Batteries/Tactic/PrintPrefix.lean
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ by setting `showTypes` to `false`:
The complete set of flags can be seen in the documentation
for `Lean.Elab.Command.PrintPrefixConfig`.
-/
elab (name := printPrefix) "#print" tk:"prefix"
cfg:(Lean.Parser.Tactic.config)? name:ident : command => liftTermElabM do
let nameId := name.getId
let opts ← elabPrintPrefixConfig (mkOptionalNode cfg)
let mut msgs ← matchingConstants opts nameId
if msgs.isEmpty then
if let [name] ← resolveGlobalConst name then
msgs ← matchingConstants opts name
logInfoAt tk (.joinSep msgs.toList "")
elab (name := printPrefix) tk:"#print " colGt "prefix"
cfg:(Lean.Parser.Tactic.config)? name:(ident)? : command => liftTermElabM do
if let some name := name then
let opts ← elabPrintPrefixConfig (mkOptionalNode cfg)
let mut msgs ← matchingConstants opts name.getId
if msgs.isEmpty then
if let [name] ← resolveGlobalConst name then
msgs ← matchingConstants opts name
logInfoAt tk (.joinSep msgs.toList "")
4 changes: 4 additions & 0 deletions test/print_prefix.lean
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,7 @@ TestInd.toCtorIdx : TestInd → Nat
-/
#guard_msgs in
#print prefix TestInd

-- `#print prefix` does nothing if no identifier is provided
#guard_msgs in
#print prefix

0 comments on commit 1e0bf50

Please sign in to comment.