-
Notifications
You must be signed in to change notification settings - Fork 721
[vernac] refine check for unresolved evars #12759
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,16 @@ | ||
| File "stdin", line 8, characters 5-22: | ||
| Error: Cannot infer field y2p of record point2d in environment: | ||
| p : point2d | ||
|
|
||
| The command has indeed failed with message: | ||
| The following term contains unresolved implicit arguments: | ||
| (fun p : point2d => {| x2p := x2p p + 1; y2p := ?y2p |}) | ||
| More precisely: | ||
| - ?y2p: Cannot infer field y2p of record point2d in environment: | ||
| p : point2d | ||
| The command has indeed failed with message: | ||
| The following term contains unresolved implicit arguments: | ||
| (fun p : point2d => {| x2p := x2p p + (fun n : nat => ?n) 1; y2p := ?y2p |}) | ||
| More precisely: | ||
| - ?n: Cannot infer this placeholder of type "nat" in | ||
| environment: | ||
| p : point2d | ||
| n : nat | ||
| - ?y2p: Cannot infer field y2p of record point2d in environment: | ||
| p : point2d |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -642,14 +642,32 @@ let declare_assumption ~name ~scope ~hook ~impargs ~uctx pe = | |
| dref | ||
|
|
||
| (* Preparing proof entries *) | ||
| 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. Exposing more API for this use case seems a bit too ad-hoc to me. |
||
| (Pretype_errors.UnsolvableImplicit (e,None))) | ||
| in | ||
| CErrors.user_err (hov 0 begin | ||
| str "The following term contains unresolved implicit arguments:"++ fnl () ++ | ||
| str " " ++ Printer.pr_econstr_env env sigma t ++ fnl () ++ | ||
| str "More precisely: " ++ fnl () ++ | ||
| v 0 (prlist_with_sep cut pr_unresolved_evar (Evar.Set.elements evars)) | ||
| end) | ||
|
|
||
| let check_evars_are_solved env sigma t = | ||
| let t = EConstr.of_constr t in | ||
| let evars = Evarutil.undefined_evars_of_term sigma t in | ||
| if not (Evar.Set.is_empty evars) then error_unresolved_evars env sigma t evars | ||
|
|
||
| let prepare_definition ~info ~opaque ~body ~typ sigma = | ||
| let { Info.poly; udecl; inline; _ } = info in | ||
| let env = Global.env () in | ||
| Pretyping.check_evars_are_solved ~program_mode:false env sigma; | ||
| let sigma, (body, types) = Evarutil.finalize ~abort_on_undefined_evars:true | ||
| let sigma, (body, types) = Evarutil.finalize ~abort_on_undefined_evars:false | ||
| sigma (fun nf -> nf body, Option.map nf typ) | ||
| in | ||
| Option.iter (check_evars_are_solved env sigma) types; | ||
| check_evars_are_solved env sigma body; | ||
| let univs = Evd.check_univ_decl ~poly sigma udecl in | ||
| let entry = definition_entry ~opaque ~inline ?types ~univs body in | ||
| let uctx = Evd.evar_universe_context sigma in | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.