Skip to content

Commit 365191c

Browse files
committed
fixes
1 parent d2d45e8 commit 365191c

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

scripts/create_deprecated_modules.lean

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Authors: Damiano Testa
55
-/
66

77
--import Mathlib.Init
8+
import Std.Time.Format
89
import Std.Time.Zoned
910
import Lean.Meta.Tactic.TryThis
1011
-- a comment here to test `keepTrailing
@@ -49,8 +50,12 @@ It returns just the imports of `fileContent`, including trailing comments if `ke
4950
-/
5051
def getHeader (fname fileContent : String) (keepTrailing : Bool) : IO String := do
5152
let (stx, _) ← Parser.parseHeader (Parser.mkInputContext fileContent fname)
52-
let stx := if keepTrailing then stx.raw else stx.raw.unsetTrailing
53-
let some substring := stx.getSubstring? | throw <| .userError "No substring: we have a problem!"
53+
let imports := stx.raw.getArg 2 -- extract just the imports list
54+
let imports := if keepTrailing then imports else imports.unsetTrailing
55+
-- Use `withLeading := false` to exclude leading comments (e.g. copyright header) that the
56+
-- parser now attaches to the first token (see leanprover/lean4#12662).
57+
let some substring := imports.getSubstring? (withLeading := false) |
58+
throw <| .userError "No substring: we have a problem!"
5459
return substring.toString
5560

5661
/--
@@ -374,7 +379,8 @@ the deprecations later on.
374379
-- #find_deleted_files 0
375380

376381
/--
377-
info: import Std.Time.Zoned
382+
info: import Std.Time.Format
383+
import Std.Time.Zoned
378384
import Lean.Meta.Tactic.TryThis
379385
-/
380386
#guard_msgs in
@@ -384,7 +390,8 @@ run_cmd
384390
logInfo head
385391

386392
/--
387-
info: import Std.Time.Zoned
393+
info: import Std.Time.Format
394+
import Std.Time.Zoned
388395
import Lean.Meta.Tactic.TryThis
389396
-- a comment here to test `keepTrailing
390397
-/

0 commit comments

Comments
 (0)