Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/nightly-testing' into lean4-pr…
Browse files Browse the repository at this point in the history
…-3756
  • Loading branch information
FR-vdash-bot committed Apr 24, 2024
2 parents f89639d + 4864395 commit 7e3b339
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
1 change: 0 additions & 1 deletion Std/Data/Array/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Gabriel Ebner
-/
import Std.Data.List.Lemmas
import Std.Data.Array.Init.Lemmas
import Std.Data.Array.Basic
import Std.Tactic.SeqFocus
import Std.Util.ProofWanted
Expand Down
1 change: 1 addition & 0 deletions Std/Data/Array/Merge.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Copyright (c) 2022 Jannis Limperg. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jannis Limperg
-/
import Std.Tactic.Alias

namespace Array

Expand Down
19 changes: 7 additions & 12 deletions Std/Tactic/PrintPrefix.lean
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,11 @@ private def lexNameLt : Name -> Name -> Bool
| .str _ _, .num _ _ => false
| .str p m, .str q n => m < n || m == n && lexNameLt p q

private def appendMatchingConstants (msg : MessageData) (opts : PrintPrefixConfig) (pre : Name)
: MetaM MessageData := do
private def matchingConstants (opts : PrintPrefixConfig) (pre : Name)
: MetaM (Array MessageData) := do
let cinfos ← getMatchingConstants (matchName opts pre) opts.imported
let cinfos := cinfos.qsort fun p q => lexNameLt (reverseName p.name) (reverseName q.name)
let mut msg := msg
let ppInfo cinfo : MetaM MessageData := do
cinfos.mapM fun cinfo => do
if opts.showTypes then
pure <| .ofPPFormat { pp := fun
| some ctx => ctx.runMetaM <|
Expand All @@ -87,9 +86,6 @@ private def appendMatchingConstants (msg : MessageData) (opts : PrintPrefixConfi
} ++ "\n"
else
pure m!"{ppConst (← mkConstWithLevelParams cinfo.name)}\n"
for cinfo in cinfos do
msg := msg ++ (← ppInfo cinfo)
pure msg

/--
The command `#print prefix foo` will print all definitions that start with
Expand Down Expand Up @@ -122,9 +118,8 @@ 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 msgappendMatchingConstants "" opts nameId
if msg.isEmpty then
let mut msgsmatchingConstants opts nameId
if msgs.isEmpty then
if let [name] ← resolveGlobalConst name then
msg ← appendMatchingConstants msg opts name
if !msg.isEmpty then
logInfoAt tk msg
msgs ← matchingConstants opts name
logInfoAt tk (.joinSep msgs.toList "")
1 change: 1 addition & 0 deletions test/print_prefix.lean
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ TEmpty.recOn.{u} (motive : TEmpty → Sort u) (t : TEmpty) : motive t
#guard_msgs in
#print prefix TEmpty -- Test type that probably won't change much.

/-- info: -/
#guard_msgs in
#print prefix (config := {imported := false}) Empty

Expand Down

0 comments on commit 7e3b339

Please sign in to comment.