-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make loose docstrings into elaboration errors rather than parse…
… errors Now loose docstrings will not yield a confusing parser error and instead log an "unexpected docstring" elaboration error and continue processing. Furthermore, if the docstring is preceding the `in` command combinator, it will add a hint to the error: ``` unexpected doc string Hint: the docstring must come after '... in', immediately before the declaration that accepts a docstring. ``` Closes #3135
- Loading branch information
Showing
4 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/-! | ||
# Loose docstrings | ||
-/ | ||
|
||
/-! | ||
Basic test | ||
-/ | ||
|
||
section | ||
/-- This is a loose docstring -/ | ||
--^ collectDiagnostics | ||
end | ||
|
||
section | ||
/-- This is a loose docstring before an 'in' command. -/ | ||
--^ collectDiagnostics | ||
set_option pp.all true in | ||
def x := 0 | ||
|
||
-- Still elaborates the `def` | ||
#check x | ||
--^ textDocument/hover | ||
end | ||
|
||
section | ||
set_option pp.all true in | ||
/-- This is a docstring in its correct position. -/ | ||
def y := 0 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{"version": 1, | ||
"uri": "file:///3135.lean", | ||
"diagnostics": | ||
[{"source": "Lean 4", | ||
"severity": 1, | ||
"range": | ||
{"start": {"line": 9, "character": 0}, "end": {"line": 10, "character": 0}}, | ||
"message": "unexpected doc string", | ||
"fullRange": | ||
{"start": {"line": 9, "character": 0}, "end": {"line": 11, "character": 3}}}, | ||
{"source": "Lean 4", | ||
"severity": 1, | ||
"range": | ||
{"start": {"line": 14, "character": 0}, "end": {"line": 15, "character": 0}}, | ||
"message": | ||
"unexpected doc string\n\nHint: the docstring must come after '... in', immediately before the declaration that accepts a docstring.", | ||
"fullRange": | ||
{"start": {"line": 14, "character": 0}, | ||
"end": {"line": 17, "character": 10}}}, | ||
{"source": "Lean 4", | ||
"severity": 3, | ||
"range": | ||
{"start": {"line": 20, "character": 0}, "end": {"line": 20, "character": 6}}, | ||
"message": "x : Nat", | ||
"fullRange": | ||
{"start": {"line": 20, "character": 0}, | ||
"end": {"line": 20, "character": 6}}}]} | ||
{"textDocument": {"uri": "file:///3135.lean"}, | ||
"position": {"line": 20, "character": 7}} | ||
{"range": | ||
{"start": {"line": 20, "character": 7}, "end": {"line": 20, "character": 8}}, | ||
"contents": {"value": "```lean\nx : Nat\n```", "kind": "markdown"}} |