Hi,
I am scratching my head on the following issue
I have this basic test
Inductive foo :=
| stupid_long_name_1
| stupid_long_name_stupid_long_name_1.
Definition bar (f : foo) :=
match f with
| stupid_long_name_1 => true
| stupid_long_name_stupid_long_name_2 => false (* <- typo *)
end.
I would have expected Coq (8.14) to report an issue on this line, since there is an obvious typo. However, stepping in VSCoq and compilation from the command line using Dune reports no issue.
Is there any limits on the length of identifiers used in such case? Can someone test in his setup and confirm?
Generally speaking, is there a list of known implementation restrictions? I cannot find one in the reference manual.
Thanks
You are under the assumption that this is actually a typo. It is not. It is perfectly legal Coq code. That is why you get no error.
(But if you swap both lines in the match with
, you should get an error message.)
Indeed, I get
Pattern "stupid_long_name_1" is redundant in this clause.
So this is counterintuitive to me. What is the rationale to accept this? Does this apply only to the last element?
Paolo Giarrusso has marked this topic as unresolved.
There seems to be something else going on...
In VsCoq I see this:
Inductive foo :=
| stupid_long_name_1
| stupid_long_name_stupid_long_name_1
| w_args (x : nat).
Set Warnings "unused-pattern-matching-variable". (* Nothing shown below *)
(* Set Warnings "+unused-pattern-matching-variable". gives an error instead*)
Definition bar (f : foo) :=
match f with
| stupid_long_name_1 => true
(* | w_args x => true *)
| x => false (* <- typo *)
end.
so if the warning is enabled, or by default, I see nothing, but if I make it an error the code fails
but this might not be the first warning that's omitted by VsCoq, so that might be an orthogonal problem
I see the warning fine with it enabled-not-error
Thanks for the investigation
I tested the snippet provided by Paolo with "unused-pattern-matching-variable".
|w_args x ...
is commented out, I see a warning (or error if "+" used) both in VSCoq and when building from the command ilneSince the behavior is consistent from the command line and from within VSCoq, this looks like an issue with Coq itself. I am using 8.14 at the moment, I need to upgrade to 8.15 to see if this is still an issue
it looks like intentional behaviour, I just don't know the reasoning
The reasoning seems to be explained here: https://github.com/coq/coq/pull/12768#issuecomment-700227387
I.e., many more warnings would have been triggered in the stdlib in this case.
I don't think this makes a strong argument, so this should be possible to evolve this warning to also include this case.
I tried changing it and it only triggered about 5 times in the stdlib
maybe I should submit
(I ended up unsure how to phrase the warning and doc so I deleted my branch)
Hi, (sorry this felt off my radar)
@Gaëtan Gilbert , is there a GitHub issue in Coq dev or PR to track this? I find the idea of an additional warning great. Thanks for investigatin this.
you can make an issue
Will do. Yet the title I use here is inaccurate. Do you have one to suggest? Thanks!
@Jerome Hugues I just made a PR: https://github.com/coq/coq/pull/16135 is there an issue I should mark as closed?
@Pierre Roux sorry i missed this message. Sure, this could be considered as closed per the reviews on Github. Thanks!
Last updated: Feb 08 2023 at 23:03 UTC