Skip to content

Errors instead of static warnings in analyzer for Setter declarations issues #42179

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

Open
sgrekhov opened this issue Jun 4, 2020 · 1 comment
Labels
area-dart-model For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer. dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug

Comments

@sgrekhov
Copy link
Contributor

sgrekhov commented Jun 4, 2020

According to the Dart Language Specification (Version 2.8.0-dev, April 22, 2020) 10.3 Setters

It is a static warning if a setter declares a return type other than void. It is
a static warning if a class has a setter named v= with argument type T and a
getter named v with return type S, and S may not be assigned to T.

In fact there are errors in analyzer in both of these cases and no issues in VM

class C {
  int set foo(var x) => 42; // In Analyzer 'error - The return type of the setter must be 'void' or absent.'  and no issues in VM
}

main() {
  new C().foo = 1;
}
class C<T extends int, S extends String> {
  set foo(T t) {
    _foo = t;
  }

  S get foo { return _foo; } // In Analyzer error - The return type of getter 'foo' is 'S' which isn't assignable to the type 'T' of its setter 'foo' and no issues in VM

  var _foo;
}

main() {
  new C<int, String>().foo = 42;
}

According to the specification there must be a static warnings in both of these cases not an errors
dartanalyzer version 2.9.0-13.0.dev

@devoncarew devoncarew added the legacy-area-analyzer Use area-devexp instead. label Jun 4, 2020
@eernstg
Copy link
Member

eernstg commented Jun 8, 2020

Cf. dart-lang/language#1012.

@srawlins srawlins added the dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec label Jun 16, 2020
@srawlins srawlins added the P4 label Jan 23, 2021
@srawlins srawlins added P3 A lower priority bug or feature request and removed P4 labels Nov 30, 2021
@srawlins srawlins added the type-enhancement A request for a change that isn't a bug label Mar 13, 2024
@bwilkerson bwilkerson added area-dart-model For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer. and removed legacy-area-analyzer Use area-devexp instead. labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-dart-model For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer. dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants