Skip to content
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

[vernac] refine check for unresolved evars #12759

Merged
merged 1 commit into from
Aug 21, 2020

Conversation

gares
Copy link
Member

@gares gares commented Jul 28, 2020

Since 8.12 Declare calls Pretyping check for unresolved evars, but this check is both too strict and produces non informative error messages. In particular you get stuff like "could not resolve an implicit of type Type" without even printing the term in which it occurs. Having a larger evar map is just OK and has use cases even if you are not using Program and hence you are not preparing an obligation. Since ~allow_evar flag has gone there is not way to circumvent this change in the API. Finally, there is no API to restrict an evar map so that the current API is happy with it (at lease, I could not find it).

In this PR I refine the check for unresolved evars to be both more informative and precise (only unresolved evars actually occurring in the term generate an error).

I'd really like this patch or a variant of it to be in 8.12.1.

A more clean solution would be to have Evarutil.finalize produce the nice error message in the first place rather than an anomaly, but that change would be more intrusive, and I'd like this patch to be backported. Upon request I can prepare another PR with this change.

@gares gares added kind: user messages Error messages, warnings, etc. kind: regression Problems that were not present in previous versions. kind: internal API, ML documentation... labels Jul 28, 2020
@gares gares added this to the 8.12.1 milestone Jul 28, 2020
@gares gares requested a review from a team as a code owner July 28, 2020 13:02
@coqbot
Copy link
Contributor

coqbot commented Jul 28, 2020

For your complete information, the job test-suite:4.11+trunk+dune in allow failure mode has failed for commit adb5936: [vernac] refine check for undresolved evars

@coqbot
Copy link
Contributor

coqbot commented Jul 28, 2020

For your complete information, the job test-suite:base+async in allow failure mode has failed for commit adb5936: [vernac] refine check for undresolved evars

@gares gares added the needs: fixing The proposed code change is broken. label Jul 28, 2020
@gares gares force-pushed the fix-prepare-definition branch from adb5936 to 39b09c4 Compare July 29, 2020 09:12
@gares gares removed the needs: fixing The proposed code change is broken. label Jul 29, 2020
@gares gares force-pushed the fix-prepare-definition branch from 39b09c4 to 246686b Compare July 29, 2020 09:26
gares added a commit to LPCIC/coq-elpi that referenced this pull request Jul 31, 2020
Copy link
Contributor

@SkySkimmer SkySkimmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks useful.

The error should probably be some new exception with registered handler instead of user_err.

A more clean solution would be to have Evarutil.finalize produce the nice error message in the first place rather than an anomaly, but that change would be more intrusive, and I'd like this patch to be backported. Upon request I can prepare another PR with this change.

I request ;)

let error_unresolved_evars env sigma t evars =
let pr_unresolved_evar e =
hov 2 (str"- " ++ Printer.pr_existential_key sigma e ++ str ": " ++
Himsg.explain_pretype_error env sigma
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could expose explain_unsolvable_implicit for this. Not sure if that's better.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, either I stay like this or we craft a new error that take the evar set and the term and that is printed as I do.
I mean, move all of the new code to Himsg.

Exposing more API for this use case seems a bit too ad-hoc to me.

@SkySkimmer SkySkimmer self-assigned this Aug 18, 2020
@SkySkimmer SkySkimmer added the needs: test-suite update Test case should be added to / updated in the test-suite. label Aug 18, 2020
@SkySkimmer SkySkimmer force-pushed the fix-prepare-definition branch from a3d777e to a7e54ad Compare August 20, 2020 14:23
@SkySkimmer SkySkimmer force-pushed the fix-prepare-definition branch from a7e54ad to d269b70 Compare August 20, 2020 14:24
@SkySkimmer
Copy link
Contributor

Did a bit of squashing and merged the 2 tests (I originally got confused because I didn't understand that missing record fields are treated as holes).
Should be ready to merge after CI.

@SkySkimmer SkySkimmer removed the needs: test-suite update Test case should be added to / updated in the test-suite. label Aug 20, 2020
@coqbot
Copy link
Contributor

coqbot commented Aug 20, 2020

For your complete information, the job test-suite:4.11+trunk+dune in allow failure mode has failed for commit d269b70: [vernac] refine check for unresolved evars

@gares
Copy link
Member Author

gares commented Aug 20, 2020

OK thanks

@gares
Copy link
Member Author

gares commented Aug 20, 2020

all green!

@SkySkimmer
Copy link
Contributor

@coqbot: merge now

@coqbot coqbot merged commit 5db27e4 into rocq-prover:master Aug 21, 2020
@SkySkimmer
Copy link
Contributor

A more clean solution would be to have Evarutil.finalize produce the nice error message in the first place rather than an anomaly, but that change would be more intrusive, and I'd like this patch to be backported. Upon request I can prepare another PR with this change.

@gares Will you have time to do that?

@gares gares deleted the fix-prepare-definition branch August 21, 2020 09:44
@gares
Copy link
Member Author

gares commented Aug 21, 2020

Thanks for merging.

I won't have time today, nor the next week :-/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: internal API, ML documentation... kind: regression Problems that were not present in previous versions. kind: user messages Error messages, warnings, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants