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

Renamed arguments get misaligned after closing doubly nested sections #12755

Closed
jashug opened this issue Jul 25, 2020 · 1 comment · Fixed by #18393
Closed

Renamed arguments get misaligned after closing doubly nested sections #12755

jashug opened this issue Jul 25, 2020 · 1 comment · Fixed by #18393
Labels
kind: bug An error, flaw, fault or unintended behaviour.
Milestone

Comments

@jashug
Copy link
Contributor

jashug commented Jul 25, 2020

Description of the problem

When Global Arguments ... : rename is used within a section within another section, when the outer section is closed the names get messed up.

Section A.
Context {a : nat}.
Section B.
Context {b : nat}.

Definition foo (eq1 : a = a) (eq2 : b = b) (c : nat) : c = c := eq_refl.
Global Arguments foo _ _ d : rename.

End B.
About foo.
(*
foo : forall {b : nat}, a = a -> b = b -> forall c : nat, c = c
Arguments foo {b}%nat_scope eq1 eq2 d%nat_scope : rename
*)

End A.
About foo.
(*
foo : forall {a b : nat}, a = a -> b = b -> forall c : nat, c = c
Arguments foo {a eq1}%nat_scope eq2 d _%nat_scope : rename
*)

Check foo (eq1 := 3) (eq_refl 2) (eq_refl 3) 4.

See above how after End A the name b is dropped and all the names are shifted one place to the left.

Coq Version

Coq master 55f4095, but also appears to have existed for the past 9 years since the renaming feature was introduced in 39fd2b1.

Root cause

| _, (ReqGlobal (c, names), _ as req) when not (isVarRef c && Lib.is_in_section c) ->
(try
let vars = Lib.variable_section_segment_of_reference c in
let var_names = List.map (NamedDecl.get_id %> Name.mk_name) vars in
let names' = var_names @ names in
Some (ReqGlobal (c, names), (c, names'))

Here we only prepend the most recent section's variables to the list of original names.

@jashug jashug added the kind: bug An error, flaw, fault or unintended behaviour. label Jul 25, 2020
herbelin added a commit to herbelin/github-coq that referenced this issue Dec 9, 2023
@herbelin
Copy link
Member

herbelin commented Dec 9, 2023

Fixed in #18393.

herbelin added a commit to herbelin/github-coq that referenced this issue Dec 10, 2023
coqbot-app bot added a commit that referenced this issue Dec 11, 2023
…ted in nested sections

Reviewed-by: SkySkimmer
Co-authored-by: SkySkimmer <SkySkimmer@users.noreply.github.com>
@coqbot-app coqbot-app bot added this to the 8.19+rc1 milestone Dec 11, 2023
SkySkimmer pushed a commit to SkySkimmer/coq that referenced this issue Dec 13, 2023
SkySkimmer added a commit to SkySkimmer/coq that referenced this issue Dec 13, 2023
SkySkimmer pushed a commit that referenced this issue Dec 14, 2023
SkySkimmer added a commit that referenced this issue Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug An error, flaw, fault or unintended behaviour.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants