Skip to content

Fail to infer types of members in on classes. #51123

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
Cat-sushi opened this issue Jan 25, 2023 · 3 comments
Open

Fail to infer types of members in on classes. #51123

Cat-sushi opened this issue Jan 25, 2023 · 3 comments
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 strict-analysis-needed Mark issues where strict-raw-types, strict-inference and similar analysis options were helpful type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@Cat-sushi
Copy link

With implicit-dynamic: false analysis option,
Dart SDK version: 2.19.0 (stable) (Unknown timestamp) on "linux_x64"
fails to infer types of members in on classes.

2.18.6 or former version of SDK didn't report any issue.

Missing field type for 'md'.
Try adding an explicit type, or remove implicit-dynamic from your analysis options file.dart(implicit_dynamic_field)
class C {
  double d = 0.0;
}

mixin M on C {
  late final md = d;
}

class C2 extends C with M {
}

void main(){
  var c = C2();
  print(c.md);
}
@Cat-sushi
Copy link
Author

Is this related to #50383 ?

@asashour
Copy link
Contributor

asashour commented Jan 25, 2023

One can use

analyzer:
  language:
    strict-raw-types: true

instead of

analyzer:
  strong-mode:
    implicit-dynamic: false

There is a quick fix in the dev channel, but it seems it isn't there for 2.19.

@srawlins srawlins added the legacy-area-analyzer Use area-devexp instead. label Jan 25, 2023
@srawlins
Copy link
Member

srawlins commented Jan 25, 2023

Hmm I find this to be very unexpected. Here's a slightly smaller example:

class C {
  double d = 0.0;
}

mixin M on C {
  late final md = d;
  
  void f() => md.x;
}

md.x should, I believe, be an error. In Dart 2.18 ("old" channel on DartPad) it is. In Dart 2.19, it is not. Our inference seems to have changed, such that the type of md is inferred to be dynamic.

CC @scheglov @stereotype441

@pq pq added the P3 A lower priority bug or feature request label Jan 25, 2023
@eernstg eernstg added the strict-analysis-needed Mark issues where strict-raw-types, strict-inference and similar analysis options were helpful label Apr 18, 2023
@srawlins srawlins added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Mar 14, 2024
@srawlins srawlins added the dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec label Sep 27, 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 strict-analysis-needed Mark issues where strict-raw-types, strict-inference and similar analysis options were helpful type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

6 participants