--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
As Brian noted, we are allowed to add additional Hints that go beyond the errors and warnings in the spec, so we do plan to address #1 very soon.
As Brian noted, we are allowed to add additional Hints that go beyond the errors and warnings in the spec, so we do plan to address #1 very soon.#2 is problematic because "doing the right thing" (as we did in the past) means suppressing a valid warning from the spec. While we can't do that by default as the default must conform to the spec, we have discussed whether we should add a user option to use type inference to actually suppress spec warnings in cases of apparent false positives like #2. We certainly can do it and have the code to do (as evidenced by the older behavior), but we have not yet answered the question of whether we should do it. There is much ongoing debate on that topic.
-Eric
On Tuesday, August 27, 2013 9:26:00 AM UTC-4, Alexandre Ardhuin wrote:1. Now (in Dart Editor version 0.6.21_r26639) I have to explicitly indicate the type of a variableHi all,The last two release of Dart Editor brought some changes (on type handling) in Dart Analyzer that makes me really sad. The 2 main concerns are :
String s1 = '';
s1.wtf; // a warning appears
final s2 = '';
s2.wtf; // no warning here !!!!
If I understand correctly, s2 is now handled as dynamic. That means that any change on the type of s2 will not produce warning.
I have almost always used this second form of variable's declaration in all my codes and it will be really hard to modify all the declarations. But if I don't make that change I will not be able to get warnings if some methods change or go away
2. http://dartbug.com/12651
class MyBase {
}
class MySub extends MyBase {
int x = 0;
}
void main() {
MyBase o = new MySub();
if (o is MySub && o.x > 0) { // warning on o.x although it is a MySub
}
}The first point is really REALLY annoying (I think many people will be affected by this change) and I can't imagine the amount of work to add types everywhere :-(
CheersAlexandre
--
As Brian noted, we are allowed to add additional Hints that go beyond the errors and warnings in the spec, so we do plan to address #1 very soon.
Is there a tracking bug for this so that we can star it and gauge user demand here?
Likewise, is there a bug for not showing warnings in cases where inference makes it obvious that they are invalid?
Not really, no.
Is there a tracking bug for this so that we can star it and gauge user demand here?
Likewise, is there a bug for not showing warnings in cases where inference makes it obvious that they are invalid?
Getting a warning in code like:var foo = ...if (foo is String) foo.length;Doesn't add any value to the life of any Dart user on Earth.
Alexandre,The editor team has plans to add "hints" for problems that can be detected by using propagated type information, which should address your first concern. I don't have a time frame for when this will happen, but this is likely to be one of the next hints that we add, so I'm hoping we'll be able to add it fairly soon.
The editor team has plans to add "hints" for problems that can be detected by using propagated type information, which should address your first concern. I don't have a time frame for when this will happen, but this is likely to be one of the next hints that we add, so I'm hoping we'll be able to add it fairly soon.question: are these hints only for "final" or do they work for "var" as well?
They will be anywhere where we can correctly propagate type information, which means for "var" as well as long as the local variable isn't used in a closure in a way that would potentially invalidate type propagation.
This is language lawyer insanity!
Displaying proven false positives is a big usability loss.
Have a setting in the editor to suppress warnings that it knows are false. And set it by default.You say there is much ongoing debate on the topic. Can you explain what the argument for false positives is?
On Tuesday, August 27, 2013 12:08:45 PM UTC-4, Eric Clayberg (Google) wrote:As Brian noted, we are allowed to add additional Hints that go beyond the errors and warnings in the spec, so we do plan to address #1 very soon.#2 is problematic because "doing the right thing" (as we did in the past) means suppressing a valid warning from the spec. While we can't do that by default as the default must conform to the spec, we have discussed whether we should add a user option to use type inference to actually suppress spec warnings in cases of apparent false positives like #2. We certainly can do it and have the code to do (as evidenced by the older behavior), but we have not yet answered the question of whether we should do it. There is much ongoing debate on that topic.-Eric
On Tuesday, August 27, 2013 9:26:00 AM UTC-4, Alexandre Ardhuin wrote:1. Now (in Dart Editor version 0.6.21_r26639) I have to explicitly indicate the type of a variableHi all,The last two release of Dart Editor brought some changes (on type handling) in Dart Analyzer that makes me really sad. The 2 main concerns are :
String s1 = '';
s1.wtf; // a warning appears
final s2 = '';
s2.wtf; // no warning here !!!!
If I understand correctly, s2 is now handled as dynamic. That means that any change on the type of s2 will not produce warning.
I have almost always used this second form of variable's declaration in all my codes and it will be really hard to modify all the declarations. But if I don't make that change I will not be able to get warnings if some methods change or go away
2. http://dartbug.com/12651
class MyBase {
}
class MySub extends MyBase {
int x = 0;
}
void main() {
MyBase o = new MySub();
if (o is MySub && o.x > 0) { // warning on o.x although it is a MySub
}
}The first point is really REALLY annoying (I think many people will be affected by this change) and I can't imagine the amount of work to add types everywhere :-(
CheersAlexandre
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
Given that the warnings are mandated by the spec, all implementations must report them. It is undesirable if each tool implements its own heuristics. We do not want a program developed without warnings on one tool to cause warnings on another.
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
Anyone can cite specific examples of false warnings
It is difficult to specify what the rules that exclude such cases are.
Otherwise they would already be excluded by the language spec.
Given that the warnings are mandated by the spec, all implementations must report them.
It is undesirable if each tool implements its own heuristics. We do not want a program developed without warnings on one tool to cause warnings on another.
This behavior is by no means unusual or unique to Dart. It is easy to show examples where one can see that a complaint given by a compiler is unwarranted in any statically typed language.
What Dart has done is raise the bar for user expectations. In a normal statically typed language, you are forced to restructure code to the compiler's satisfaction. With the introduction of optional typing, people are demanding more than they have ever asked from conventional type systems. Since they can run the code despite the warnings, they see no reason to change the code; they want the warnings to either be undeniably valid or go away.
The question then is whether we can accommodate these expectations and how.
The proposal should be looked at in that light. We have debated the question of how to silence spurious warnings since day 1.
We do have to agree on a mechanism for handling this, but there are other possibilities than this specific proposal.
1) Add a standard-compliant-warnings option to the editor for these use cases.
2) Have these tools use the same analyzer as the editor.
3) Optionally tell the tools to ignore warnings.
Can we at least agree that forcing the editor to disable type inferencing hurts programmer usability?
It hurts for me. I want my IDE to be as smart as possible.
Can't we compromise by adding an option to the editor to force spec-compliant warnings?
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
If I have understood it correctly, the reasoning behind spec-mandated warnings is:Developers don't like warnings. They generally prefer to write programs that don't cause warnings when compiled/run. It's mainly a safety and hygiene choice - irrelevant warnings can drown out important ones if you get used to seeing them.If different tools have different warnings, it's impossible for a developer to know whether another will see warnings. If your IDE silences some warnings, you won't realize that you are releasing code that will cause these warnings in other tools.
So, every tool must show the same warnings, and therefore they must be specified centrally.That also means that there is a limit on what can be specified, because the spec can't allow heuristics that may be interpreted differently, and it takes effort away from the language development to develop the static analysis in the spec as well.Ofcourse that's only going to work if tool developers care about making their tools warning-spec compliant. The dartlang project managed tools like the Dart Editor, the dart analyzer and the dart2js compiler try to follow the spec. The VM doesn't generate static warnings at all.
Now we have users of the Editor asking for a non-spec compliant warning omissions. I would personally have no problem with having that as an opt-in choice.
It's the user's development tool and development environment, and we should not take options away from it, especially if they are already there.If anything, I would like the error display in the Editor to have very easily used toggles to toggle between different error/warning filters. Then the analyzer can generate all the warnings, and the editor can show the ones the user cares about right now.I expect third-party tools to do whatever they want in order to please their users, and giving a *known* useless warning is not helping anybody, so it'd be one of the first uses of a type analysis in any IDE.
We already see some tools display more warnings (call them "hints" instead if it would be a spec violation to call them "warnings"). You implicitly opt into those warnings by choosing the tool, and the tool may have a way to disable them. That means that the original goal is already defeated, so maybe we should reconsider it.
Otherwise they would already be excluded by the language spec.That would indeed be the ideal solution.
It is undesirable if each tool implements its own heuristics. We do not want a program developed without warnings on one tool to cause warnings on another.
Ideally, we should come up with a set of agreed upon heuristics (it could be a small set of very obvious cases to start) and then have all of the tools implement them. Codifying them in the spec would be even better.
Now we have users of the Editor asking for a non-spec compliant warning omissions. I would personally have no problem with having that as an opt-in choice.
I disagree. The fact that this frequently comes up on the mailing list means that some developers would enable it, and there would be lots of libraries with warnings.
--
Eric,
Otherwise they would already be excluded by the language spec.That would indeed be the ideal solution.It is undesirable if each tool implements its own heuristics. We do not want a program developed without warnings on one tool to cause warnings on another.Ideally, we should come up with a set of agreed upon heuristics (it could be a small set of very obvious cases to start) and then have all of the tools implement them. Codifying them in the spec would be even better.I strongly disagree.Codifying these rules in the specification would have the negative effect that in the future when we discovered another useful heuristic we wouldn't be able to implement it because it wasn't in the specification. Changing language specifications is a slow and arduous process (certainly once the specification has been declared to be stable). All this would accomplish is to further restrict the ability of tool providers to innovate for their users.
What Dart has done is raise the bar for user expectations. In a normal statically typed language, you are forced to restructure code to the compiler's satisfaction. With the introduction of optional typing, people are demanding more than they have ever asked from conventional type systems. Since they can run the code despite the warnings, they see no reason to change the code; they want the warnings to either be undeniably valid or go away.
Why does the specification for these warnings need to be the Dart Language Specification? Why can it not be in a separate specification? The process for changing this specification would not need to be slow and arduous.
Clearly no amount of arguing is going to change anything at this point.
Surely the editor/analyzer team has already fought and lost this battle
they can't have been happy being forced to turn off a lot of their type inferencing code just for some hypothetical future benefit of tool error consistency.
The best way to be heard on this issue is to vote with our feet.
On Wed, Aug 28, 2013 at 4:10 PM, Lasse R.H. Nielsen <l...@google.com> wrote:
If I have understood it correctly, the reasoning behind spec-mandated warnings is:Developers don't like warnings. They generally prefer to write programs that don't cause warnings when compiled/run. It's mainly a safety and hygiene choice - irrelevant warnings can drown out important ones if you get used to seeing them.If different tools have different warnings, it's impossible for a developer to know whether another will see warnings. If your IDE silences some warnings, you won't realize that you are releasing code that will cause these warnings in other tools.
So, every tool must show the same warnings, and therefore they must be specified centrally.That also means that there is a limit on what can be specified, because the spec can't allow heuristics that may be interpreted differently, and it takes effort away from the language development to develop the static analysis in the spec as well.Ofcourse that's only going to work if tool developers care about making their tools warning-spec compliant. The dartlang project managed tools like the Dart Editor, the dart analyzer and the dart2js compiler try to follow the spec. The VM doesn't generate static warnings at all.
Now we have users of the Editor asking for a non-spec compliant warning omissions. I would personally have no problem with having that as an opt-in choice.I disagree. The fact that this frequently comes up on the mailing list means that some developers would enable it, and there would be lots of libraries with warnings.
It's the user's development tool and development environment, and we should not take options away from it, especially if they are already there.If anything, I would like the error display in the Editor to have very easily used toggles to toggle between different error/warning filters. Then the analyzer can generate all the warnings, and the editor can show the ones the user cares about right now.I expect third-party tools to do whatever they want in order to please their users, and giving a *known* useless warning is not helping anybody, so it'd be one of the first uses of a type analysis in any IDE.I hate special casing, but if the "if (x is Y)" check was dealt with, almost all useless warnings were gone for me.
Other warnings might be wrong, but I would understand that I shouldn't write code this way. So I vote in favor of adding this exception to the spec. Yes: we would get requests for better type-inference, but I would be much more comfortable rejecting those.
Currently I have to add type annotations everywhere to benefit (analyzer, code completion) and still have situations left where I get unhelpful warnings (Alexandre' case 2).This is the most annoying combination of all options (I understand that the entire discussion is about solving this issue).
Dart is a dynamic language and should behave like static for some scenarios (code completion, static analyzing/error checking, ...?)
var s = 'string';s.
Günter,Dart is a dynamic language and should behave like static for some scenarios (code completion, static analyzing/error checking, ...?)Just to be clear, the only requirement is that tools must produce errors and warnings based on the static type information. There is no restriction on other functionality such as code completion, and Editor uses the propagated type information whenever possible. If you have enteredvar s = 'string';s.code completion, for example, will show you choices appropriate to a String (which it knows because of type propagation).
Maybe an additional keyword to distinguish when the type inference is demanded an when dynamic behavior is wanted would help (like var/dynamic in c#) .
At least in the case of "var" or "dynamic", it won't show a warning, so using "var" is one way to avoid the spurious warnings.
Showing warnings based on inference (now called Hints) will be coming back soon!
> I'd love to see other examples of tortured refactorings caused by
this change (as ammo for encouraging a better solution).
Every class I have that overrides the == operator got a bit sadder.
Example:
bool operator ==(Object other) {
if(identical(this, other)) return true;
if(*other is! Rectangle*)returnfalse;
*Rectangle o = other;*
return left == o.left && top == o.top
&& width == o.width && height == o.height;
I'd love to see other examples of tortured refactorings caused by this change (as ammo for encouraging a better solution).
Gack! I think I just threw up a little in my mouth.
I think the point is that being forced to use the as-operator or perform an inelegant refactoring to avoid a warning that the tools already know is bogus is painful... both to the users (including a great many folks on the Dart team itself) as well as to the team providing the tools. And I do have a low tolerance for self-inflicted pain...
On Fri, Aug 30, 2013 at 4:35 AM, Eric Clayberg (Google) <clay...@google.com> wrote:
Gack! I think I just threw up a little in my mouth.wow. either you are exaggerating or your tolerance is extremely low...Yes. this is a common pattern.Justin could have used the as-operator, but apparently preferred the nested if.
On Thu, Aug 29, 2013 at 1:58 PM, Bob Nystrom <rnys...@google.com
<mailto:rnys...@google.com>> wrote:
On Thu, Aug 29, 2013 at 1:43 PM, Eric Clayberg (Google)
<clay...@google.com <mailto:clay...@google.com>> wrote:
At least in the case of "var" or "dynamic", it won't show a
warning, so using "var" is one way to avoid the spurious warnings.
My problem is not too many spurious warnings, it's too few
legitimate ones because I use var everywhere. :(
If it wasn't for great test coverage, I wouldn't be able to
refactor any of my Dart code anymore. Ever since the analyzer
stopped showing warnings through inference, it's basically like
flying blind.
+1. I think these are the options:
1. give up on static analysis completely, and rely on tests for
refactoring, like you would in JavaScript.
2. put type annotations everywhere, and make code ugly like Java. Fix
the style guide to require this style.
3. be optimistic and hope tools can be made better...
So far I've chosen #3, but it ends up being /de facto/ equivalent to
#1. Either way is a sad result. If I'm following the thread so far, we
already know how to make the analyzer better, but are not doing it
because ???
(side note: I don't understand the desire to support more than one
analysis tool that implements warnings, either. Surely we can just
implement it once and be done with it? What is the value in
implementing it twice?)
+1. I think these are the options:
- give up on static analysis completely, and rely on tests for refactoring, like you would in JavaScript.
- put type annotations everywhere, and make code ugly like Java. Fix the style guide to require this style.
- be optimistic and hope tools can be made better...
So far I've chosen #3, but it ends up being de facto equivalent to #1. Either way is a sad result. If I'm following the thread so far, we already know how to make the analyzer better, but are not doing it because ???
Difficulties with type inference in checked mode in the DartVM?
On Fri, Aug 30, 2013 at 10:13 AM, Florian Loitsch <floi...@google.com> wrote:
On Fri, Aug 30, 2013 at 4:35 AM, Eric Clayberg (Google) <clay...@google.com> wrote:
Gack! I think I just threw up a little in my mouth.wow. either you are exaggerating or your tolerance is extremely low...Yes. this is a common pattern.Justin could have used the as-operator, but apparently preferred the nested if.Cast has a non-zero cost, and it's a potential change in behavior in production mode.
If I'm following the thread so far, we already know how to make the analyzer better, but are not doing it because ???
(side note: I don't understand the desire to support more than one analysis tool that implements warnings, either. Surely we can just implement it once and be done with it? What is the value in implementing it twice?)
John,If I'm following the thread so far, we already know how to make the analyzer better, but are not doing it because ???Actually, we are actively working to make the analyzer better. We're actually doing this on three fronts simultaneously.First, we're trying to convince the language team to loosen some of the restrictions on tools so that we can have a more optimal solution. This thread and a couple of issues in the issue tracker are at the forefront of that effort.Second, we're working on putting support in place to report hints when propagated type information tells us that there's a problem that static type information didn't identify. These hints will be clearly different from specified warnings, but will hopefully be easy to use.Third, as an alternative in case the first effort doesn't get us anywhere, we're looking into ways of identifying specified warnings generated based on static type information that wouldn't have been generated if we had used propagated type information. How that will manifest itself in both Editor and the command line analyzer is being discussed, but we're hopeful that we can do something that is good for the user while still remaining spec. compliant.
(side note: I don't understand the desire to support more than one analysis tool that implements warnings, either. Surely we can just implement it once and be done with it? What is the value in implementing it twice?)One of the primary reasons at the moment is the fact that both dart2js and the Editor need the results of an analysis, but they are written using different languages (Dart and Java respectively) and there is no Java to Dart interop story.
One thing I am wondering: will hints will be available outside of the editor, for example by running "dartanalyzer"? Essentially if I have a codebase and I want it to be statically checked, can it be done aside from manually opening code in the Editor?
I think that's why I'm confused -- why does dart2js need to emit warnings, when the VM does not? Couldn't we use dartanalyzer in both cases?
Static warnings must be provided by Dart compilers used for program development such as those incorporated in IDEs or otherwise intended to be used by developers for developing code. Compilers that are part of runtime execution environments such as virtual machines should not issue static warnings.
Dart has to be language where the tools permit reliable refactoring based on the type warnings. For me very about much of Dart's resonance is lost if that capability is weakened to severely. The thought of a "javascript experience" where one must code without that ability and depend totally on test coverage is awful. That's a barrier to Dart's adoption for the production of large scale applications and is exactly the opposite of Dart's reason to exist - at least as I've come to know it.
Front and center on dartlang.org is this message: "A new language, with tools and libraries, for structured web app engineering". So I see a message that has "structured wep app engineering". Not a performance message, or a novel optional type message, or new packaging, or vm, or whatever. It's about the ability of the language to support large scale application development. If tools are not generating good, purposeful, errors, warnings, and hints, to guide the production of quality "structured web app" code the there is a real problem. This issue seems rather fundamental in this regard.
I think that's why I'm confused -- why does dart2js need to emit warnings, when the VM does not? Couldn't we use dartanalyzer in both cases?The specification reads:Static warnings must be provided by Dart compilers used for program development such as those incorporated in IDEs or otherwise intended to be used by developers for developing code. Compilers that are part of runtime execution environments such as virtual machines should not issue static warnings.Both dart2js and dartanalyzer fall into the first category, and both are required to be spec. compliant. Hence, both need to produce all of the warnings from the specification.
Yeah, but it still doesn't make sense why the spec says that :).
(Or why dart2js can't implement it by shelling out to dartanalyzer.)
A typical development cycle is something like:edit -> refresh -> (repeat) -> analyze -> edit -> (repeat) -> (repeat all) ... -> deploy -> ...I would use a cycle like this whether using the Dart Editor or some other editor.In other words, I would like the analyzer to be much sooner in the cycle than deployment. Ideally integrated with the editor itself (as Dart Editor does). By the time I run dart2js, I have already run the analyzer many times. I don't need dart2js to run the same analysis again.