-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add option to consider error message feedbacks as failures (& Fix retract bugs) #238
Conversation
Thanks @psteckler, but this patch doesn't seem to work: with example #232 (comment), both "point 1" and "point 2" cases now trigger some awkward behavior... |
I will try that example. |
With the "retract-on-feedback" option enabled, the behavior for the "point 1" and "point 2" cases is the same. The error in You don't want to retract to state So instead, PG/xml sets the point to the start of the span for The |
With the latest commit, in the example, the point should be at the start of the marked-in-red "false". There's also some other cleanup. |
Thanks @psteckler! I'll test this tomorrow. |
Hi @psteckler! However with I'm attaching a video that describes the 3 bugs that show up with 543ce8d and Hopefully you can take a look on this afternoon. Edit: the file being used in the video is (*
GNU Emacs 25.1.1 under GNU/Linux with
PG commit 543ce8d67e6f53f15b7475463fba9a975ed315d9
Coq version 8.7.2
OCaml version 4.06.1
(setq coq-errormsg-as-failure nil)
*)
Definition f (n : nat) := n. (* first, evaluate this line *)
Definition bug1 := f false. (* point 1 *)
Definition bug2 := f false. (* point 2 *) |
@psteckler
|
@erikmd I made some "optimizations" to the handle-failure case that were just plain wrong, explaining the change in behavior. I've fixed that (not yet pushed), and in the goto-point-1 case, the failure causes a retraction to the preceding statement, and the point is at the beginning of the The goto-point-2 case differs between Coq With 8.5, adding the two buggy statements succeed, but there's a fail-value when we ask for the current goal. That fail-value has a valid state id corresponding to the first statement, the With |
Indeed, thanks 👍 |
BTW did you reproduce the other bug I mentioned in the video with Coq 8.7.2 ? |
I've just pushed a commit, so that if a fail-value has a dummy state id, we look up the state id associated with the span for the last statement added. That is, we try to retract exactly one statement. For the goto-point-2 case with |
I will look at this now. |
With 8.7.2 and |
@psteckler, it is indeed a fail-value (I believed it was a bare error-message because it was yellow for a bit longer than usually, but in the end the error indeed becomes red, as expected) |
@psteckler Sorry I'm a bit confused as I did another test with the latest version of the PR (a252075), and it seems that the goto-point-2 behavior has changed: when |
Yes, with Before my change, the fail-value with a dummy state id did not cause a retraction. I'm pretty sure that's a Coq bug: a fail-value should tell you what the last valid state id is. The current behavior works around that bug, and gives the same result as 8.5. |
Sorry but I'm not sure I follow you. Even if there is a fail-value, in "goto-point-2" mode, isn't PG supposed to process all the phrases and not retract ? |
To be more precise: i think the "goto-point-1" mode (when one evaluates only one Coq phrase) is very fine now and with the option you implemented in this PR it will nicely solve #232. But IMO the "goto-point-2" behavior we are talking about could be somewhat reverted to that of 543ce8d, because that behavior tested in my video-based bugreport was OK. |
Besides, if we evaluate the small running example file in a row, we now get in the mini-buffer the error message for the first definition, while the cursor is retracted to the second definition: you can test with
BTW could you recall what would be the emblematic example of error-message with no fail-value ? |
PG is simply responding to what Coq sends. For the "goto-point-2" case, there is a fail-value sent by Coq. If we add an additional statement:
and goto point 3, there is no fail-value sent, just the error feedbacks. In that case, PG processes |
OK I see, thanks for your explanation! :) |
Finally as I mentioned in my last-but-one comment, maybe one improvement could be done to avoid that at the same time, PG retracts to the last error at "point 2" (assuming there is no "point 3") but shows the error message for the first error at "point 1". What do you think? |
This is a funny one, indeed. What happens is the cascade of fail-values and retracts I mentioned earlier, which starts with the fail-value containing a dummy state id. The last retract is triggered by a fail-value for Strangely, with 8.5, where we get a fail-value with a valid state id after processing In any case, both errors are highlighted, and you can mouse-hover to see the error messages for each one. |
With 8.7.2/ |
The example with It seems to depend when PG asks for the goal. If it's immediately after a statement that generates an error feedback, you get a fail-value. If there's an intervening statement that does not generate an error feedback, there's no fail-value. It's that second case that allows for async proof processing in the presence of errors, because you can continue to process statements. |
Note: this is all very confusing! :-) |
Yes: I tested the example and each error indeed has an error-message tooltip, which is very handy. But both error-messages in the tooltips are the same (corresponding to the first error-message) with Coq 8.7.2. |
I observe the same little bug with Coq 8.6.1 |
Indeed it's a bit tricky :-) but I guess we'll be able to document it somewhere in the wiki for example, so that users feel more familiar with it. |
That's a bug. I'll look into it now.
I believe that sending a dummy state id in a fail-value is a Coq bug. The code in this PR is doing its best to work around it. |
BTW @psteckler feel free to add a separate commit in this PR if you can fix that remaining bug related to retraction and error messages (we'll be able to squash-and-merge if need be) |
Thanks @psteckler! I just tested the latest version of the PR (e9b61aa) with Coq 8.6.1 and Coq 8.7.2, both with |
@erikmd actually, I just pushed a fix for that bug. When PG gets a fail-value, it queues the error message to display later. It was using the span for the last statement sent for that, even though the fail-value error may have come from an earlier statement, as in this case. With the fix, PG looks at the state id that it's retracting to, and associates the error with the statement that was In this case, we see just the error in |
@erikmd Great, you might want to look again with this latest bug fix, though it should only affect error highlighting. |
@psteckler Yes, this is exactly the version I tested, with your latest bug fix (cf. the SHA1 in my comment) so the tooltips for error highlighting are very OK :-) |
There is an option, settable in
coq/coq-system.el
, to consider feedbacks with error message as failures, so they cause a retraction to the start of the span associated with the state id in the feedback.Not well-tested, works on simple examples.
Fixes #232.