Skip to content

disable warning 30 (same constructor/label used in two mutually-recursive declarations)#9046

Merged
gasche merged 1 commit intoocaml:trunkfrom
gasche:disable-warning-30-by-default
Oct 18, 2019
Merged

disable warning 30 (same constructor/label used in two mutually-recursive declarations)#9046
gasche merged 1 commit intoocaml:trunkfrom
gasche:disable-warning-30-by-default

Conversation

@gasche
Copy link
Copy Markdown
Member

@gasche gasche commented Oct 16, 2019

Warning 30 warns when the same constructor/label is used in two
mutually-recursive type declarations. This warning (added in OCaml
3.12, 2010) was meaningful at the time where constructor/label
conflicts had a shadowing semantics: the "last" definition would mean,
while ideally mutually-recursive definitions should not be strictly
ordered but defined "all at once".

Since OCaml 4.01 (2013) we support type-based disambiguation of
constructor/label names and it is now common to write code such as,
say

type pattern = Var of var | ...
type expr = Var of var | ...

(no warning, of course). But warning 30 fires if you instead write

type pattern = Var of var | ...
and expr = Var of var | ...

This doesn't make much sense, and in particular it certainly makes no
sense to enable this warning by default. The present PR disables it by
default.

@gasche gasche force-pushed the disable-warning-30-by-default branch from dfaa169 to 92a260f Compare October 16, 2019 16:23
…sive decls)

Warning 30 warns when the same constructor/label is used in two
mutually-recursive type declarations. This warning (added in OCaml
3.12, 2010) was meaningful at the time where constructor/label
conflicts had a shadowing semantics: the "last" definition would mean,
while ideally mutually-recursive definitions should not be strictly
ordered but defined "all at once".

Since OCaml 4.01 (2013) we support type-based disambiguation of
constructor/label names and it is now common to write code such as,
say

    type pattern = Var of var | ...
    type expr = Var of var | ...

(no warning, of course). But warning 30 fires if you instead write

    type pattern = Var of var | ...
    and expr = Var of var | ...

This doesn't make much sense, and in particular it certainly makes no
sense to enable this warning by default. The present PR disables it by
default.
@gasche
Copy link
Copy Markdown
Member Author

gasche commented Oct 17, 2019

@Drup if you like the PR, would you mind approving it? (Or maybe you like it but you are not sure it should be merged?)

Copy link
Copy Markdown
Contributor

@trefis trefis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely agreed.

@gasche
Copy link
Copy Markdown
Member Author

gasche commented Oct 18, 2019

In general for warnings we would have to be fairly careful with the default settings (they affect the language model and require Serious Consensus to be changed), but in this particular I'm pretty sure that everyone just forgot about this warning and it's a mistake that it slipped through unnoticed so far. (Probably because most existing codebases didn't start using same-constructor-names overnight so we didn't notice it.)

The reason I created this PR now is that a new intern of mine just wrote code that fell on this warning, and that was a bad user experience.

I thus propose to move on and merge as the CI is green. @trefis, does that sound reasonable to you?

@trefis
Copy link
Copy Markdown
Contributor

trefis commented Oct 18, 2019

It does.

Although if you want to be extra careful, you could try and confirm that your explanation is correct by digging into old issues / blaming the code and looking at the commit message (or asking its author).

@gasche
Copy link
Copy Markdown
Member Author

gasche commented Oct 18, 2019

Ah, I did the digging part already: MPR#3601 in 2010.

@gasche gasche merged commit 01a3420 into ocaml:trunk Oct 18, 2019
gasche added a commit to gasche/dune that referenced this pull request Dec 26, 2023
Warning 30 (same constructor/label name used in two mutually-recursive
declarations) is an annoying warning that makes no sense since we
introduced type-based disambiguation of fields and constructors. It
was disabled by default in OCaml 4.10

  ocaml/ocaml#9046

and there is no reason to keep it in Dune.

Signed-off-by: Gabriel Scherer <gabriel.scherer@gmail.com>
gasche added a commit to gasche/dune that referenced this pull request Dec 26, 2023
Warning 30 (same constructor/label name used in two mutually-recursive
declarations) is an annoying warning that makes no sense since we
introduced type-based disambiguation of fields and constructors. It
was disabled by default in OCaml 4.10

  ocaml/ocaml#9046

and there is no reason to keep it in Dune.

Signed-off-by: Gabriel Scherer <gabriel.scherer@gmail.com>
gasche added a commit to gasche/dune that referenced this pull request Dec 27, 2023
Warning 30 (same constructor/label name used in two mutually-recursive
declarations) is an annoying warning that makes no sense since we
introduced type-based disambiguation of fields and constructors. It
was disabled by default in OCaml 4.10

  ocaml/ocaml#9046

and there is no reason to keep it in Dune.

Signed-off-by: Gabriel Scherer <gabriel.scherer@gmail.com>
rgrinberg pushed a commit to gasche/dune that referenced this pull request Dec 28, 2023
Warning 30 (same constructor/label name used in two mutually-recursive
declarations) is an annoying warning that makes no sense since we
introduced type-based disambiguation of fields and constructors. It
was disabled by default in OCaml 4.10

  ocaml/ocaml#9046

and there is no reason to keep it in Dune.

Signed-off-by: Gabriel Scherer <gabriel.scherer@gmail.com>
gasche added a commit to gasche/dune that referenced this pull request Dec 28, 2023
Warning 30 (same constructor/label name used in two mutually-recursive
declarations) is an annoying warning that makes no sense since we
introduced type-based disambiguation of fields and constructors. It
was disabled by default in OCaml 4.10

  ocaml/ocaml#9046

and there is no reason to keep it in Dune.

Signed-off-by: Gabriel Scherer <gabriel.scherer@gmail.com>
gasche added a commit to gasche/dune that referenced this pull request Jan 4, 2024
Warning 30 (same constructor/label name used in two mutually-recursive
declarations) is an annoying warning that makes no sense since we
introduced type-based disambiguation of fields and constructors. It
was disabled by default in OCaml 4.10

  ocaml/ocaml#9046

and there is no reason to keep it in Dune.

Signed-off-by: Gabriel Scherer <gabriel.scherer@gmail.com>
Co-authored-by: Rudi Grinberg <me@rgrinberg.com>
rgrinberg added a commit to gasche/dune that referenced this pull request Jan 8, 2024
Warning 30 (same constructor/label name used in two mutually-recursive
declarations) is an annoying warning that makes no sense since we
introduced type-based disambiguation of fields and constructors. It
was disabled by default in OCaml 4.10

  ocaml/ocaml#9046

and there is no reason to keep it in Dune.

Signed-off-by: Gabriel Scherer <gabriel.scherer@gmail.com>
Co-authored-by: Rudi Grinberg <me@rgrinberg.com>
rgrinberg added a commit to gasche/dune that referenced this pull request Jan 8, 2024
Warning 30 (same constructor/label name used in two mutually-recursive
declarations) is an annoying warning that makes no sense since we
introduced type-based disambiguation of fields and constructors. It
was disabled by default in OCaml 4.10

  ocaml/ocaml#9046

and there is no reason to keep it in Dune.

Signed-off-by: Gabriel Scherer <gabriel.scherer@gmail.com>
Co-authored-by: Rudi Grinberg <me@rgrinberg.com>
rgrinberg pushed a commit to ocaml/dune that referenced this pull request Jan 8, 2024
Warning 30 (same constructor/label name used in two mutually-recursive
declarations) is an annoying warning that makes no sense since we
introduced type-based disambiguation of fields and constructors. It
was disabled by default in OCaml 4.10

  ocaml/ocaml#9046

and there is no reason to keep it in Dune.

Signed-off-by: Gabriel Scherer <gabriel.scherer@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants