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

Add a hint- Missing warning for attempt to set the unsettable but gettable field #17166

Closed
DartBot opened this issue Feb 27, 2014 · 12 comments
Closed
Labels
analyzer-warning Issues with the analyzer's Warning codes area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Feb 27, 2014

This issue was originally filed by @tatumizer


class Foo {
  get foo=>null;
}
class Bar {
  var _bar;
  set bar(x)=>_bar=x;
}
main() {
  var f=new Foo();
  f.foo=1; // no warning
  var b=new Bar();
  print(b.bar); // warning!
}
Attempt to get the ungettable but settable field is flagged, but the reverse is not true

@lrhn
Copy link
Member

lrhn commented Feb 27, 2014

Added Area-Analyzer, Triaged labels.

@bwilkerson
Copy link
Member

Added this to the 1.3 milestone.
Removed Priority-Unassigned label.
Added Priority-Medium label.

@jwren
Copy link
Member

jwren commented Mar 27, 2014

First off, there are no warnings at all being generated. The warning that you have above, is actually a hint. In Dart only the static types are used to generate warnings. In this case f and b are both dynamic since they are declared with 'var'.

If the 'var's are changed to the type, warnings appear in both cases.

class Foo {
  get foo=>null;
}
class Bar {
  var _bar;
  set bar(x)=>_bar=x;
}
main() {
  Foo f=new Foo();
  f.foo=1; // warning
  Bar b=new Bar();
  print(b.bar); // warning
}

Leaving the issue open to create the missing hint on 'foo'.

Also- All hint related issues are being marked as Milestone-Later.


cc @bwilkerson.
Set owner to @jwren.
Removed this from the 1.3 milestone.
Added this to the Later milestone.
Changed the title to: "[Hint] Add a hint- Missing warning for attempt to set the unsettable but gettable field".

@DartBot
Copy link
Author

DartBot commented Mar 27, 2014

This comment was originally written by @tatumizer


Leaving the issue open to create the missing hint on 'foo'.
But that was the whole issue.
"Attempt to get the ungettable but settable field is flagged, but the reverse is not true"
I never complained about anything else. And does it really matter that you call warning "a hint"? It's yellow anyway.
Thanks for paying attention.

@jwren
Copy link
Member

jwren commented Mar 27, 2014

I forgot to say thank you for the feedback.

I'm not disagreeing with you, and we'll add it as soon as we can spend more time on hints.

If you are interested in contributing to the analyzer, it is open source, we'd be happy to have external contributors! The change to add this missing hint won't be hard, just a bit tedious.

@DartBot
Copy link
Author

DartBot commented Mar 27, 2014

This comment was originally written by @tatumizer


No problem :-). I know you are working hard guys. I couldn't be even 1/10
as productive as any of you, even in my best years (which are a couple of
decades in the past), so any "contribution" from me will take more time to
review and fix than to implement in-house.
Thanks again, I appreciate your work, and I think the language has a great
future. I really enjoy programming again (which I thought would never
happen).

@clayberg
Copy link

clayberg commented Apr 1, 2014

Added Analyzer-Hint label.

@bwilkerson
Copy link
Member

Changed the title to: "Add a hint- Missing warning for attempt to set the unsettable but gettable field".

@jwren
Copy link
Member

jwren commented Apr 2, 2014

Removed Type-Defect label.
Added Type-Enhancement label.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@DartBot DartBot added Type-Enhancement area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-warning Issues with the analyzer's Warning codes labels Aug 4, 2014
@jwren jwren removed their assignment Oct 6, 2015
@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug and removed triaged labels Mar 1, 2016
@srawlins
Copy link
Member

This is implemented as a strong mode warning.

$ cat 17166.dart
class Foo {
  get foo=>null;
}
class Bar {
  var _bar;
  set bar(x)=>_bar=x;
}
main() {
  var f=new Foo();
  f.foo=1; // no warning
  var b=new Bar();
  print(b.bar); // warning!
}

$ dartanalyzer --strong 17166.dart
Analyzing [17166.dart]...
[warning] No setter named 'foo' in class 'Foo' (/Users/srawlins/code/17166.dart, line 10, col 5)
[warning] The getter 'bar' is not defined for the class 'Bar' (/Users/srawlins/code/17166.dart, line 12, col 11)
[hint] The value of the field '_bar' is not used (/Users/srawlins/code/17166.dart, line 5, col 7)
2 warnings and 1 hint found.

@srawlins srawlins closed this as completed Apr 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-warning Issues with the analyzer's Warning codes area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

8 participants