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

Confusing Analyzer output when package language version is too old for null safety #42321

Closed
natebosch opened this issue Jun 12, 2020 · 6 comments
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. NNBD Issues related to NNBD Release

Comments

@natebosch
Copy link
Member

In a package where the language version in package_config.json is < 2.9 and a library with a // @dart = 2.9 comment, running dartanalyzer --enable-experiment=non-nullable . prints:

  error • This requires the 'non-nullable' language feature to be enabled. • foo.dart:10:20 • experiment_not_enabled
1 error found.

It would be less confusing if the error message said something about not being able to opt in to a newer language version with a comment than what is in the package_config.json. Or potentially even better, if it let you use the experiment anyway. This is on a recent dev SDK.

@natebosch natebosch added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Jun 12, 2020
@natebosch
Copy link
Member Author

See also #42323 where the CFE/VM have an output which is also confusing.

@leafpetersen leafpetersen added the NNBD Issues related to NNBD Release label Jun 12, 2020
@scheglov scheglov self-assigned this Jun 15, 2020
@scheglov
Copy link
Contributor

@leafpetersen Is behavior of // @dart = specified anywhere?

Currently in analyzer we start with some set of language features, default, or with enabled experiments; and then this set passes through two phases of restricting - the first time based on the package config, and the second time based on the // @dart override.

So, if we specify a higher language version than for the whole package, it is no-op, the features have already been removed from the set.

It seems right from the perspective of migrating a package library by library.

@leafpetersen
Copy link
Member

@leafpetersen Is behavior of // @dart = specified anywhere?

Here

And more specifically here

@scheglov
Copy link
Contributor

Great, thank you!

@scheglov
Copy link
Contributor

dart-bot pushed a commit that referenced this issue Jun 16, 2020
#42274
#42321

Change-Id: I5551ecd2803f9d26e720e5cf5671b3be8236bce9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151423
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
@scheglov
Copy link
Contributor

One more related fix 60bb0d3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. NNBD Issues related to NNBD Release
Projects
None yet
Development

No branches or pull requests

3 participants