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

Shadow warnings: 44 refined into 52,53 for alphanumeric identifiers and symbolic operators #232

Closed
wants to merge 4 commits into from

Conversation

gasche
Copy link
Member

@gasche gasche commented Aug 15, 2015

For more details on warnings when open-shadowed identifiers are used, see the discussion and pointers in PR#6951.

In this proposed PR, warning 44 is preserved exactly as is (the goal is to help forward- and backward-compatibility), and two new warnings are added that refine its behavior: 52 fires on alphanumeric shadowing when 44 is disabled, and 53 fires on symbolic shadowing when 44 is disabled.

A consequence of this compatibility strategy (up for discussion) is that people using +A-44 will see new warnings appearing (one must now use +A-44-52-53 for the same effect).

I think we could consider enabling +52 (shadowing of alphanumeric identifier) by default in 4.03, but this patch does not implement it.

Note that with the proposed implementation, (asr), (mod) etc. are considered symbolic operators.

This is useful to distinguish alphabetic identifiers from infix or
prefix operators (it will count "mod", "asr" etc. as infix operators,
which I think the user would expect). This definition is robust to
changes of the OCaml lexical conventions -- whereas testing s.[0] for
('a'..'z' | '_') is not.
…prefix operators

The warning 44 (identifier shadowed by open) is split into 52
(alphanumeric identifier) and 53 (infix or prefix operators). 44 is
kept as-is and should keep behaving in the exact same way (note that
turning it into 52 only would have the bad property that warning-free
code using @44 in 4.03 could break on older OCaml versions). "asr",
"mod" and other magic infix identifiers are considered infix
operators, not alphanumeric identifiers.
@Drup
Copy link
Contributor

Drup commented Aug 17, 2015

Same as before, not completely convinced by the distinction operator/identifier but it's at least better than before.

Do you think we should have M.!(...) too ? I feel like it still serves a purpose, even with the new warning. Most people that cares will probably do -44-53, but might occasionally want to shadow an identifier.

Also, -44 is basically useless in your scheme, why not just say "-44 is equivalent to -53-52" ?

@gasche
Copy link
Member Author

gasche commented Aug 17, 2015

I have mixed feelings about M.!(...), so right now I'm trying to focus my (limited) efforts on finer-grained shadowing criterions to make any use of open! less necessary.

The warnings work in a very simple way today, in particular enabling/disabling a warning never acts over other warning settings. I thought about schemes were (un)selecting 44 would implicitly impact 52/53, but ultimately I think that the simplicity of the current system is more important. It is also rather difficult to reason about backward- and forward- compatibility, and I think it is best to make sure that 44 behaves exactly as before on non-erroneous¹ programs.

¹: The first version of my PR guaranteed that 44 would work exactly as before on all programs, in particular a program with A@52 would warn on 44 and then error on 52. The current version does not warn on 44 in this case (it feels a bit superfluous), so the compatibility guarantee is that 44 behaves as before on non-erroneous programs (only).

Note that 44 is not enabled by default today, so the only people using -44 are those using A, and those should be used to micro-manage their warnings. I expect more people to add warnings to the default set (so they now have the choice to replace +44 into +52 if they wish -- and we could discuss adding +52 by default), or explicitly list all warnings they want to enable (the most compatible solution).

@Drup
Copy link
Contributor

Drup commented Aug 17, 2015

I have mixed feelings about M.!(...), so right now I'm trying to focus my (limited) efforts on finer-grained shadowing criterions to make any use of open! less necessary.

"Less" doesn't mean "not", and having only open! is inconsistent.

@dbuenzli
Copy link
Contributor

I think we could consider enabling +52 (shadowing of alphanumeric identifier) by default in 4.03,

I have little interest in tweaking warning flags in each of my projects. Provide the good defaults as this seems to be the right one.

@gasche
Copy link
Member Author

gasche commented Aug 17, 2015

@dbuenzli ok, but adding a new warning by default need to be discussed (compatibility concerns etc.), and I would rather dissociate this discussion from the present PR itself. Also, you are an opinionated person, so I don't think it is realistic to hope that you will always be satisfied with the set of warnings by default. (how would a person of taste accept not to enable 40 as an error?)

It is bad to change the semantics of a warning after it has been released, which means that the semantics of 52/53 will be set in stone after the 4.03 release (no idea when that will be). I might try to refine their behavior a bit before that -- for example maybe try to implement the idea of not warning if the shadowing and shadowed bindings are alias of each other. I have thought a bit about it, but it is not as simple to implement.

@gasche
Copy link
Member Author

gasche commented Nov 19, 2015

We discussed this at the developer meeting yesterday, and the consensus was to not include the change yet and postpone a decision. Some were not convinced that the identifier/symbol split is the right way to split or refine this warning.

(I'm not sure what to do with the PR. If there was a "postponed" label I would use it.)

@agarwal
Copy link
Member

agarwal commented Nov 19, 2015

If there was a "postponed" label I would use it.

Why not create it.

@gasche
Copy link
Member Author

gasche commented Nov 19, 2015

I'm probably not in the right group (or I don't know how to do that). In the label list I can write arbitrary names in the "filter" input form, but not create a label from it. @damiendoligez , can you create a postponed/delayed/suspended label?

@agarwal
Copy link
Member

agarwal commented Nov 19, 2015

See here. You have write access to the repo, so I'm pretty sure you should be allowed to do this.

@gasche
Copy link
Member Author

gasche commented Nov 20, 2015

Thanks @agarwal ! This is the worst user interface I've seen in a long time (it's FusionForge-level obscurity), there are 8 steps described to add a label (for something which should be one click away from the "label" button visible in the right), and some of them are wrong or confusing (clicking the "ocaml" repository name in my Repositories list in profile goes to my personal clone, which is not what we want here; step 4 asks to click "Labels" on a page where two different buttons are named "Labels" and the more visible one is the wrong one), but I managed to create a "suspended" label. Yay.

@agarwal
Copy link
Member

agarwal commented Nov 20, 2015

I agree this is not too intuitive, but comparing to FusionForge is a low blow. Perhaps you'll like their new interface. It's opt-in for less than 2 weeks, and then they'll switch you over.

@damiendoligez
Copy link
Member

but adding a new warning by default need to be discussed (compatibility concerns etc.),

There are no compatibility concerns. We clearly have the right to break programs that use -warn-error A.

@damiendoligez damiendoligez added this to the 4.04-or-later milestone Jan 22, 2016
@mshinwell mshinwell removed this from the 4.04 milestone Sep 7, 2016
@damiendoligez damiendoligez added this to the 4.07-or-later milestone Sep 27, 2017
@damiendoligez damiendoligez removed this from the consider-for-4.07 milestone Jun 1, 2018
@xavierleroy
Copy link
Contributor

The latest comment on this PR goes back to January 2016, so I feel somewhat safe in closing this PR. Reopen if you still care about it.

mshinwell pushed a commit to mshinwell/ocaml that referenced this pull request Aug 13, 2020
lthls pushed a commit to lthls/ocaml that referenced this pull request Sep 23, 2020
lthls pushed a commit to lthls/ocaml that referenced this pull request Sep 23, 2020
lthls pushed a commit to lthls/ocaml that referenced this pull request Sep 24, 2020
EmileTrotignon pushed a commit to EmileTrotignon/ocaml that referenced this pull request Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants