-
Notifications
You must be signed in to change notification settings - Fork 213
Change most specified warnings to errors #1012
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
Comments
I agree with making the I still want to make the "different default value" not a warning at all. If it's not an error, then it's not a problem. People who wants the warning can still get it from the analyzer as a lint, if they want to, but then they also have a way avoid it. They can't avoid spec-mandated warnings. The switch warning on incomplete enums is probably fine as a warning (but I'd prefer to make it non-spec mandated and leave it up to the analyzer, and try to avoid warnings in the spec). |
Me too. |
@leafpetersen, @natebosch, @jakemac53, @stereotype441, do you wish to speak up against making the '(E)' cases errors in the spec? |
Making the '(E)' cases errors SGTM. |
LGTM. |
Cf. #1083. |
I guess this just must not come up in practice, but I don't know if I was aware this was a warning or error. What is the reasoning for this? |
The original intent behind library names was probably that they were intended to be more prominent. You should refer to libraries by their names, which is also what you see in the old Turned out that designing Dart for the web made imports by URIs much more practical, and ahead-of-time compiling (for the web, again) made reflection less of a feature and more of a liability. And then we allowed When the front-end needed to be able to look at individual Dart files rather than just entire programs (because it's also a front-end for the analyzer, and you can analyze a single file), we changed the conflict rules to not disallow library name conflicts "per program", but instead "in the import graph of any file", because it couldn't know whether a file was a program or not. We then slipped up when putting that into the spec, and didn't say explicitly that a file couldn't transitively import files with the same name, so the implementations only check that they don't directly import files with the same name. Nobody noticed. But basically, it's completely useless, and there is now no reason left for ever adding a library name (other than doing name based lookup in So, that's the history of library names and naming conflicts (as I understand it, I wasn't actually there for the first part). |
The historical reasoning makes sense, thanks. Given the current state of the ecosystem I think changing this from a warning to an error today has both very low positive impact, and very low risk. My personal choice might be to skip any of the risk and not bother with changing it since the impact is also so low but I don't feel strongly. The rest of the (E) LGTM. |
@johnniwinther just found another one:
Cf. #1096. |
PR #1096 now landed. |
Tests here. |
Yes. I think at the time, some even held out hope that libraries would become first class. :)
Yeah, I recall some saying all imports should be prefixed. Also, at the time I think the original designers thought libraries would be "bigger" than they turned out to be. They thought of each library as being more like, well, a library of reusable code, and not just a single file or module. Hence the name. But it turns out users don't like having a single private namespace that spans many many Dart files so libraries today tend to be the unit of maintainance more than the unit of reuse. Packages (which didn't exist at the beginning) now fill that latter role. |
Closing: Spec change and tests landed, implementation issues closed (dart-lang/sdk#42699), or included in NNBD epics (dart-lang/sdk#42700, dart-lang/sdk#42701, dart-lang/sdk#42702). |
Cf. dart-lang/sdk#36127 and dart-lang/sdk#36126, the language specification specifies a few compile-time warnings:
[]=
is explicitly declared and notvoid
. (E)void
. (E)v=
with argument type T and a getter namedv
with return type S, and S may not be assigned to T. (E)However, the treatment of these warnings has been inconsistent for a long time.
The situations marked '(E)' are currently flagged as errors by the analyzer, and '(W)' is flagged as a warning. Given that the analyzer has flagged these situations as errors for a long time, we have the option to specify them as errors without breaking existing code.
This issue serves to discuss and clarify this situation.
Here is a concrete proposal: Change the specification to specify as errors those situations that are currently flagged as errors, as indicated above.
The treatment of the getter/setter type conflict is specified for null-safety, so it will be an error soon anyway, and similarly for the switch cases.
The examples in dart-lang/sdk#36127 would be adjusted and added as language tests.
@lrhn, @munificent, @leafpetersen, WDYT?
The text was updated successfully, but these errors were encountered: