Skip to content

Commit bceff34

Browse files
committed
Compiles now... to be polished!
1 parent d11b81c commit bceff34

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

Mathlib/Tactic/Linter/TextBased.lean

+11-8
Original file line numberDiff line numberDiff line change
@@ -323,28 +323,31 @@ def broadImportsLinter : TextbasedLinter := fun lines ↦ Id.run do
323323
def trailingWhitespaceLinter : TextbasedLinter := fun lines ↦ Id.run do
324324
let mut errors := Array.mkEmpty 0
325325
let mut fixedLines := lines
326-
for i in [0::lines.size - 1] do
327-
let line := lines[i]
326+
let mut i := 0
327+
for line in lines do
328328
if line.back == ' ' then
329329
errors := errors.push (StyleError.trailingWhitespace, i + 1)
330-
fixedLines := fixedLines.set! 0 (line.dropRightWhile (· == ' '))
330+
fixedLines := fixedLines.set! i (line.dropRightWhile (· == ' '))
331+
i := i + 1
331332
return (errors, fixedLines)
332333
-- xxx: can I avoid set!, as I know the index is inbounds? is there a better way?
333334
-- ask on zulip for the most idiomatic construct
334335

335336
-- TODO: apply the same change to all other linters, once this has been tested...
336337

337-
def semicolonLinter : TextbaseLinter := fun lines ↦ Id.run do
338+
def semicolonLinter : TextbasedLinter := fun lines ↦ Id.run do
338339
let mut errors := Array.mkEmpty 0
339340
let mut fixedLines := lines
340-
for i in [0::lines.size - 1] do
341-
let line := lines[i]
341+
let mut idx := 0
342+
for line in lines do--for i in [0::lines.size - 1] do
343+
--let line := lines[i]
342344
if line.contains ';' then
343345
let replaced := (line.replace " ;" "; ").replace " " " "
344346
if replaced != line then
345-
errors := errors.push (StyleError.semicolon, i + 1) -- TODO: add error variant etc!
347+
-- errors := errors.push (StyleError.semicolon, idx + 1) -- TODO: add error variant etc!
346348
-- "Line contains a space before a semicolon"
347-
fixedLines := fixedLines.set! 0 replaced
349+
fixedLines := fixedLines.set! idx replaced
350+
idx := idx+ 1
348351
return (errors, fixedLines)
349352

350353
/-- Whether a collection of lines consists *only* of imports, blank lines and single-line comments.

0 commit comments

Comments
 (0)