-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Move the error message earlier on incomplete-tactic-followed-by-deindentation #1971
Comments
This also goes wrong when you go in the other direction, supplying too many arguments to tactics. The simplest case could arise from mixing up example (P : Prop) (h : P) : P := by
assumption P which gives the error A nasty variation if you add an extraneous argument in a calc block: example : 1 + 1 = 2 := by
calc 1 + 1 = 1 + 1 := by rfl
_ = 2 := by rfl [h]
example (P : Prop) (h : P) : P := by
exact h Here the error comes on line 5 and is |
Note that in my example everything would be much clearer if we simply went back to delimiting tactic proofs by |
Here's an example in the wild of an experienced user being totally confused by this. |
@kbuzzard It is not clear to me that this is the same class of error. Could you distill an MWE from that? |
Yes you're right, the thing I linked to is confusing but perhaps for a different reason. Re this issue: I have just been telling my students to write |
@hrmacbeth do you consider this issue is solved by #2393? |
Both my examples from #1971 (comment) now have better error messages. The first one now says: |
This is intended as a proposal for discussion. When there is an incomplete tactic call, Lean considers the error as occurring in the first place afterwards where new text appears to make it malformed. This is done even in examples like the following, when the incomplete tactic call is followed by de-indentation, so the user's intention was very likely that the new (de-indented) text be unrelated to that tactic call.
This is the same behaviour as in Lean 3, but the situation arose much more rarely there because usually there was a
begin
/end
block or a comma to contain the error to a single line.Proposal: if there is text following an incomplete tactic call which is the same or a lower indentation level, then Lean could treat the error as being located on the
exact
itself or in the space after it. (So in this case we are assuming that that later text wasn't supposed to be part of the tactic call.)This proposal comes from Mario in a Zulip discussion; he notes there that this would seem to require a change within the core parser infrastructure / somewhere around the
withPosition
parser combinator.The text was updated successfully, but these errors were encountered: