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

Printing precedence bug leading to wrong parentheses in custom entries #7

Conversation

herbelin
Copy link
Owner

@herbelin herbelin commented Feb 5, 2020

Inductive Expr := 
 | Mul : Expr -> Expr -> Expr 
 | Add : Expr -> Expr -> Expr  
 | One : Expr.   
         
Declare Custom Entry expr.    
Notation "[ expr ]" := expr (expr custom expr at level 2). 
Notation "1" := One (in custom expr at level 0).       
Notation "x y" := (Mul x y) (in custom expr at level 1, left associativity).    
Notation "x + y" := (Add x y) (in custom expr at level 2, left associativity).  
 
Check Add [1 + 1] [1 + 1].

was wrongly written [1+1+(1+1)] even though parentheses were not declared in the custom expr.

…and constr).

There was a collision at the time of interpreting subentries (in metasyntax.ml) but also
at the time of "optimizing" the entries (in egramcoq.ml).
Insertion of coercion to manage precedence of custom entries are
treated in constrextern.ml, while ppconstr.ml is only about the
management of precedences for constr.
The "Any" case was not reached formerly for ETPattern and ETConstr as
far as I can see. So there should be no change of semantics.
Also renamed it to relative_entry_level.

Correspondence between old and new representation is:
(n,L) -> LevelLt n
(n,E), (n,Prec n) -> LevelLe n
(n,Any) -> LevelSome

Should not change global semantics (except error message in pr_arg).
…n with typing coercions.

No change of semantics.
…in this entry.

Parsing was automatically supporting this. This commit adds support for printing.

Note: More delicate would be to recognize that some given entry
support applicative nodes hence abbreviations with arguments.
This is to emphasize that this is more general than just a level.

Should not change semantics.
Don't mix less-than precedences (as in "expr + expr" with an
associativity) with equal precedences (this impacts
Notation.availability_of_entry_coercion).

We introduce for that purpose a variant of "notation_entry_level"
called "notation_entry_relative_level".
@herbelin herbelin force-pushed the master+support-arg-free-abbrev-in-custom-entries-with-global branch 5 times, most recently from ffc7f2c to 5c1fb33 Compare March 3, 2020 21:14
@herbelin herbelin force-pushed the master+support-arg-free-abbrev-in-custom-entries-with-global branch from a744436 to 33aaa5d Compare April 11, 2020 08:41
jfehrle added a commit that referenced this pull request Feb 18, 2022
jfehrle added a commit that referenced this pull request Feb 18, 2022
@herbelin
Copy link
Owner Author

herbelin commented Jul 8, 2023

The printing bug was reported in coq#12775 and coq#13018. It was first fixed in coq#13073 from 8.12, with a more principle fix in coq#17117 for 8.18.

The only interesting commit is the cleanup renaming of "level" into "notation_signature" (c817660).

@herbelin herbelin closed this Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant