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

only parsing notations should not disable the printing of other notations defined after them #7443

Closed
JasonGross opened this issue May 6, 2018 · 2 comments · Fixed by #12984
Labels
part: notations The notation system.
Milestone

Comments

@JasonGross
Copy link
Member

JasonGross commented May 6, 2018

Version

8.8.0 (present as far back as 8.5, though)

Description of the problem

Consider this code:

Inductive type := nat | bool.
Definition denote (t : type)
  := match t with
     | nat => Datatypes.nat
     | bool => Datatypes.bool
     end.
Ltac reify t :=
  lazymatch eval cbv beta in t with
  | Datatypes.nat => nat
  | Datatypes.bool => bool
  end.
Notation reify t := (ltac:(let rt := reify t in exact rt)) (only parsing).
Notation reify_type_of e := (reify ((fun t (_ : t) => t) _ e)) (only parsing).
Axiom Literal : forall {t}, denote t -> Type.
Delimit Scope foo_scope with foo.
Open Scope foo_scope.
Section A.
  Notation "[ x ]" := (Literal (t:=reify_type_of x) x) (only parsing) : foo_scope.
  Check [1]. (* Literal 1 : Type *) (* as expected *)
  Notation "[ x ]" := (Literal x) : foo_scope.
  Check @Literal nat 1. (* Incorred: gives Literal 1 : Type when it should give [1] *)
  Notation "[ x ]" := (Literal (t:=reify_type_of x) x) (only parsing) : foo_scope.
  Check [1]. (* Incorrect: gives Literal 1 : Type when it should give [1] *)
End A.
Section B.
  Notation "[ x ]" := (Literal x) : foo_scope.
  Check @Literal nat 1. (* [1] : Type *)
  Fail Check [1]. (* As expected: The command has indeed failed with message:
The term "1" has type "Datatypes.nat" while it is expected to have type
 "denote ?t". *)
  Notation "[ x ]" := (Literal (t:=reify_type_of x) x) (only parsing) : foo_scope.
  Check [1]. (* Should succeed, but instead fails with: Error:
The term "1" has type "Datatypes.nat" while it is expected to have type
 "denote ?t". *)
End B.

There are two issues here:

  1. Adding the only parsing notation makes the later printing-and-parsing notation not be used for printing, which is incorrect
  2. Adding the only parsing notation after the printing-and-parsing notation does not update the parser, which is incorrect

My guess is that the notation system is incorrectly considering _ and ltac:(...) to be equal when deciding whether or not, and how, to overwrite a notation with another?

cc @herbelin

@JasonGross JasonGross added the part: notations The notation system. label May 6, 2018
@JasonGross JasonGross changed the title (only parsing) notations should not disable the printing of other notations defined after them only parsing notations should not disable the printing of other notations defined after them May 6, 2018
@herbelin
Copy link
Member

My guess is that the notation system is incorrectly considering _ and ltac:(...) to be equal when deciding whether or not, and how, to overwrite a notation with another?

Your guess is right.

What to do is a bit unclear (comparing tactic code would be a bit difficult with locations, arbitrary generic arguments, ...). Maybe assuming that two tactics always differ by default, even if exactly the same)?

@herbelin
Copy link
Member

Fixed by #12950 but the current semantics adopted in #12950 makes that redefining a notation in only-parsing mode cancels the whole of a previous combined parsing-printing notation, including its printing part.

In particular, this means displaying Literal 1 in the third and fifth example.

herbelin added a commit to herbelin/github-coq that referenced this issue Aug 31, 2020
…notations.

The (old) original model for notations was to associated both a
parsing and a printing rule to a notation.

Progressively, it was more and more common to have only parsing
notations or even multiple expressions printed with the same notation.

The new model is to attach to a given scope, string and entry at most
one either only-parsing or mixed-parsing-printing rules + an
arbitrarily many unrelated only-printing rules.

Additionally, we anticipate the ability to selectively
activate/deactivate each of those.

This allows to fix in particular coq#9682 and coq#10824 but also to have
more-to-the-point warnings in case a notation overrides or partially
overrides another one

We also improve the output of "Print Scopes" so that it adds when a
notation is only-parsing, only-printing, or deactivated, or a
combination of those.

Fixes coq#9682
Fixes coq#10824
Fixes part 2 of coq#12908
Fixes coq#7443 (up to accepting that only-parsing cancels a previous
  parsing+printing notation)
Fixes coq#4738
herbelin added a commit to herbelin/github-coq that referenced this issue Sep 4, 2020
…notations.

The (old) original model for notations was to associated both a
parsing and a printing rule to a notation.

Progressively, it was more and more common to have only parsing
notations or even multiple expressions printed with the same notation.

The new model is to attach to a given scope, string and entry at most
one either only-parsing or mixed-parsing-printing rules + an
arbitrarily many unrelated only-printing rules.

Additionally, we anticipate the ability to selectively
activate/deactivate each of those.

This allows to fix in particular coq#9682 and coq#10824 but also to have
more-to-the-point warnings in case a notation overrides or partially
overrides another one

We also improve the output of "Print Scopes" so that it adds when a
notation is only-parsing, only-printing, or deactivated, or a
combination of those.

Fixes coq#9682
Fixes coq#10824
Fixes part 2 of coq#12908
Fixes coq#7443 (up to accepting that only-parsing cancels a previous
  parsing+printing notation)
Fixes coq#4738
herbelin added a commit to herbelin/github-coq that referenced this issue Sep 5, 2020
herbelin added a commit to herbelin/github-coq that referenced this issue Sep 26, 2020
…notations.

The (old) original model for notations was to associated both a
parsing and a printing rule to a notation.

Progressively, it was more and more common to have only parsing
notations or even multiple expressions printed with the same notation.

The new model is to attach to a given scope, string and entry at most
one either only-parsing or mixed-parsing-printing rules + an
arbitrarily many unrelated only-printing rules.

Additionally, we anticipate the ability to selectively
activate/deactivate each of those.

This allows to fix in particular coq#9682 and coq#10824 but also to have
more-to-the-point warnings in case a notation overrides or partially
overrides another one

We also improve the output of "Print Scopes" so that it adds when a
notation is only-parsing, only-printing, or deactivated, or a
combination of those.

Fixes coq#9682
Fixes coq#10824
Fixes part 2 of coq#12908
Fixes coq#7443 (up to accepting that only-parsing cancels a previous
  parsing+printing notation)
Fixes coq#4738
herbelin added a commit to herbelin/github-coq that referenced this issue Sep 29, 2020
…notations.

The (old) original model for notations was to associated both a
parsing and a printing rule to a notation.

Progressively, it was more and more common to have only parsing
notations or even multiple expressions printed with the same notation.

The new model is to attach to a given scope, string and entry at most
one either only-parsing or mixed-parsing-printing rules + an
arbitrarily many unrelated only-printing rules.

Additionally, we anticipate the ability to selectively
activate/deactivate each of those.

This allows to fix in particular coq#9682 and coq#10824 but also to have
more-to-the-point warnings in case a notation overrides or partially
overrides another one

We also improve the output of "Print Scopes" so that it adds when a
notation is only-parsing, only-printing, or deactivated, or a
combination of those.

Fixes coq#9682
Fixes coq#10824
Fixes part 2 of coq#12908
Fixes coq#7443 (up to accepting that only-parsing cancels a previous
  parsing+printing notation)
Fixes coq#4738
herbelin added a commit to herbelin/github-coq that referenced this issue Oct 4, 2020
…notations.

The (old) original model for notations was to associated both a
parsing and a printing rule to a notation.

Progressively, it was more and more common to have only parsing
notations or even multiple expressions printed with the same notation.

The new model is to attach to a given scope, string and entry at most
one either only-parsing or mixed-parsing-printing rules + an
arbitrarily many unrelated only-printing rules.

Additionally, we anticipate the ability to selectively
activate/deactivate each of those.

This allows to fix in particular coq#9682 and coq#10824 but also to have
more-to-the-point warnings in case a notation overrides or partially
overrides another one

We also improve the output of "Print Scopes" so that it adds when a
notation is only-parsing, only-printing, or deactivated, or a
combination of those.

Fixes coq#9682
Fixes coq#10824
Fixes part 2 of coq#12908
Fixes coq#7443 (up to accepting that only-parsing cancels a previous
  parsing+printing notation)
Fixes coq#4738
herbelin added a commit to herbelin/github-coq that referenced this issue Oct 4, 2020
herbelin added a commit to herbelin/github-coq that referenced this issue Oct 6, 2020
…notations.

The (old) original model for notations was to associated both a
parsing and a printing rule to a notation.

Progressively, it was more and more common to have only parsing
notations or even multiple expressions printed with the same notation.

The new model is to attach to a given scope, string and entry at most
one either only-parsing or mixed-parsing-printing rules + an
arbitrarily many unrelated only-printing rules.

Additionally, we anticipate the ability to selectively
activate/deactivate each of those.

This allows to fix in particular coq#9682 and coq#10824 but also to have
more-to-the-point warnings in case a notation overrides or partially
overrides another one

We also improve the output of "Print Scopes" so that it adds when a
notation is only-parsing, only-printing, or deactivated, or a
combination of those.

Fixes coq#9682
Fixes coq#10824
Fixes part 2 of coq#12908
Fixes coq#7443 (up to accepting that only-parsing cancels a previous
  parsing+printing notation)
Fixes coq#4738
herbelin added a commit to herbelin/github-coq that referenced this issue Oct 6, 2020
herbelin added a commit to herbelin/github-coq that referenced this issue Oct 6, 2020
…notations.

The (old) original model for notations was to associated both a
parsing and a printing rule to a notation.

Progressively, it was more and more common to have only parsing
notations or even multiple expressions printed with the same notation.

The new model is to attach to a given scope, string and entry at most
one either only-parsing or mixed-parsing-printing rules + an
arbitrarily many unrelated only-printing rules.

Additionally, we anticipate the ability to selectively
activate/deactivate each of those.

This allows to fix in particular coq#9682 and coq#10824 but also to have
more-to-the-point warnings in case a notation overrides or partially
overrides another one

We also improve the output of "Print Scopes" so that it adds when a
notation is only-parsing, only-printing, or deactivated, or a
combination of those.

Fixes coq#9682
Fixes coq#10824
Fixes part 2 of coq#12908
Fixes coq#7443 (up to accepting that only-parsing cancels a previous
  parsing+printing notation)
Fixes coq#4738
herbelin added a commit to herbelin/github-coq that referenced this issue Oct 9, 2020
…notations.

The (old) original model for notations was to associated both a
parsing and a printing rule to a notation.

Progressively, it was more and more common to have only parsing
notations or even multiple expressions printed with the same notation.

The new model is to attach to a given scope, string and entry at most
one either only-parsing or mixed-parsing-printing rules + an
arbitrarily many unrelated only-printing rules.

Additionally, we anticipate the ability to selectively
activate/deactivate each of those.

This allows to fix in particular coq#9682 and coq#10824 but also to have
more-to-the-point warnings in case a notation overrides or partially
overrides another one

We also improve the output of "Print Scopes" so that it adds when a
notation is only-parsing, only-printing, or deactivated, or a
combination of those.

Fixes coq#9682
Fixes coq#10824
Fixes part 2 of coq#12908
Fixes coq#7443 (up to accepting that only-parsing cancels a previous
  parsing+printing notation)
Fixes coq#4738
herbelin added a commit to herbelin/github-coq that referenced this issue Oct 9, 2020
…notations.

The (old) original model for notations was to associated both a
parsing and a printing rule to a notation.

Progressively, it was more and more common to have only parsing
notations or even multiple expressions printed with the same notation.

The new model is to attach to a given scope, string and entry at most
one either only-parsing or mixed-parsing-printing rules + an
arbitrarily many unrelated only-printing rules.

Additionally, we anticipate the ability to selectively
activate/deactivate each of those.

This allows to fix in particular coq#9682 and coq#10824 but also to have
more-to-the-point warnings in case a notation overrides or partially
overrides another one

We also improve the output of "Print Scopes" so that it adds when a
notation is only-parsing, only-printing, or deactivated, or a
combination of those.

Fixes coq#9682
Fixes coq#10824
Fixes part 2 of coq#12908
Fixes coq#7443 (up to accepting that only-parsing cancels a previous
  parsing+printing notation)
Fixes coq#4738
@coqbot-app coqbot-app bot added this to the 8.13+beta1 milestone Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part: notations The notation system.
Projects
None yet
2 participants