Skip to content

Commit 573fd67

Browse files
committed
Upgrade to Lean toolchain to v4.26.0.
1 parent ee9caec commit 573fd67

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

PreBuild.lean

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,9 @@ def pfile : Parser Enums := do
422422
else fail s!"parsed {enums.size} enum(s), but there is some text left"
423423

424424
def prettyError
425-
(ι : String.Iterator) (content : String) (msg : String)
425+
(content : String) (ι : content.ValidPos) (msg : String)
426426
: IO String := do
427-
let pos := Parsec.Input.pos ι
427+
let pos := Parsec.Input.pos (⟨content, ι⟩ : Sigma String.ValidPos)
428428
let map := content.toFileMap
429429
let position := map.toPosition pos
430430
let char := String.Pos.Raw.get? content pos
@@ -433,15 +433,15 @@ def prettyError
433433
| '\n' | '\r' => "'<newline>'"
434434
| some c => s!"'{c}'"
435435

436-
let getLine (n : Nat) : Substring :=
436+
let getLine (n : Nat) : String :=
437437
let startPos := map.positions[n]!
438438
let endPos := map.positions[n.succ]!
439-
content.toSubstring.extract startPos endPos |>.trimRight
439+
String.Pos.Raw.extract content startPos endPos |>.trimRight
440440
let line := position.line - 1
441441
let padding := toString position.line.succ |>.length
442442
let lpad (line? : Option Nat) : String :=
443443
let s := line?.map toString |>.getD ""
444-
List.asString <| s.data.leftpad padding ' '
444+
String.ofList (List.replicate padding ' ') ++ s
445445
return (
446446
s!"error at {position.line}-{position.column} on character {charStr}"
447447
) ++ "\n" ++ (
@@ -459,8 +459,8 @@ def prettyError
459459
s!"{msg}"
460460
)
461461

462-
def presentError (ι : String.Iterator) (content : String) (msg : String) : IO Lean.Position := do
463-
let pos := Parsec.Input.pos ι
462+
def presentError (content : String) (ι : content.ValidPos) (msg : String) : IO Lean.Position := do
463+
let pos := Parsec.Input.pos (⟨content, ι⟩ : Sigma String.ValidPos)
464464
let map := content.toFileMap
465465
let position := map.toPosition pos
466466
let char := String.Pos.Raw.get? content pos
@@ -469,15 +469,15 @@ def presentError (ι : String.Iterator) (content : String) (msg : String) : IO L
469469
| '\n' | '\r' => "'<newline>'"
470470
| some c => s!"'{c}'"
471471
IO.eprintln s!"error at {position.line}-{position.column} on character {charStr}"
472-
let getLine (n : Nat) : Substring :=
472+
let getLine (n : Nat) : String :=
473473
let startPos := map.positions[n]!
474474
let endPos := map.positions[n.succ]!
475-
content.toSubstring.extract startPos endPos |>.trimRight
475+
String.Pos.Raw.extract content startPos endPos |>.trimRight
476476
let line := position.line - 1
477477
let padding := toString position.line.succ |>.length
478478
let lpad (line? : Option Nat) : String :=
479479
let s := line?.map toString |>.getD ""
480-
List.asString <| s.data.leftpad padding ' '
480+
String.ofList (List.replicate padding ' ') ++ s
481481
if 0 < line then
482482
IO.eprintln s!" {lpad position.line.pred} | {getLine line.pred}"
483483
else
@@ -497,10 +497,10 @@ def parseContentWith (p : Parser α) (content : String) (notEoiFail := true) : I
497497
Parsec.eof
498498
return res
499499
else p
500-
match p content.iter with
500+
match p content, content.startValidPos⟩ with
501501
| .success _ a => return a
502502
| .error ι msg => do
503-
let pretty ← prettyError ι content (toString msg)
503+
let pretty ← prettyError ι.fst ι.snd (toString msg)
504504
throw <| IO.Error.userError pretty
505505

506506
def parseContent : String → IO Enums :=

lean-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
leanprover/lean4:v4.25.2
1+
leanprover/lean4:v4.26.0

0 commit comments

Comments
 (0)