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

Cannot declare global typeclass field in definitional class #17451

Closed
rlepigre opened this issue Mar 31, 2023 · 2 comments · Fixed by #17485 or #17754
Closed

Cannot declare global typeclass field in definitional class #17451

rlepigre opened this issue Mar 31, 2023 · 2 comments · Fixed by #17485 or #17754
Labels
part: typeclasses The typeclass mechanism. part: vernac High level command interpretation.
Milestone

Comments

@rlepigre
Copy link
Contributor

Description of the problem

The following code:

Class Junk.

Class Dummy : Type :=
  something :> Junk.

produces the warning:

Warning: A coercion will be introduced instead of an instance in future versions when using ':>' in 'Class'
declarations. Replace ':>' with '::' (or use '#[global] Existing Instance field.' for compatibility with Coq <
8.17). Beware that the default locality for '::' is #[export], as opposed to #[global] for ':>' currently. Add an
explicit #[global] attribute to the field if you need to keep the current behavior. For example: "Class foo := {
#[global] field :: bar }." [future-coercion-class-field,records]

However, there is no way to use the syntax:

Class Dummy : Type :=
  #[global] something :: Junk.

It works without the #[global] but the something instance is then export. Of course, the other workaround with Existing Instance works, but the warning is confusing since there is no record here.

Coq Version

8.17.0

cc @Janno

@Blaisorblade Blaisorblade added part: typeclasses The typeclass mechanism. part: vernac High level command interpretation. part: records Record types, Structures, etc. labels Apr 4, 2023
@Blaisorblade
Copy link
Contributor

Since this is new with #16230, tagging @proux01 (and including the same labels as the MR).

proux01 added a commit to proux01/coq that referenced this issue Apr 9, 2023
@proux01 proux01 removed the part: records Record types, Structures, etc. label Apr 9, 2023
@proux01
Copy link
Contributor

proux01 commented Apr 9, 2023

The best solution would be to add support for locality attribute to the "single field" of definitional typeclasses, but that's non trivial and I don't have time to do that right now. So let's at least fix the confusing warning message: #17485

coqbot-app bot added a commit that referenced this issue Apr 17, 2023
…nal class)

Reviewed-by: SkySkimmer
Co-authored-by: SkySkimmer <SkySkimmer@users.noreply.github.com>
@coqbot-app coqbot-app bot added this to the 8.17.1 milestone Apr 17, 2023
Zimmi48 pushed a commit to Zimmi48/coq that referenced this issue May 16, 2023
(cherry picked from commit 43a91b9)
Zimmi48 added a commit to Zimmi48/coq that referenced this issue May 16, 2023
proux01 added a commit to proux01/coq that referenced this issue Jun 20, 2023
proux01 added a commit to proux01/coq that referenced this issue Jun 20, 2023
proux01 added a commit to proux01/coq that referenced this issue Jun 20, 2023
proux01 added a commit to proux01/coq that referenced this issue Jun 22, 2023
proux01 added a commit to proux01/coq that referenced this issue Jun 22, 2023
proux01 added a commit to proux01/coq that referenced this issue Jun 25, 2023
tom-p-reichel pushed a commit to tom-p-reichel/coq that referenced this issue Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part: typeclasses The typeclass mechanism. part: vernac High level command interpretation.
Projects
None yet
3 participants