Skip to content

Fail early when running dart migrate with too-high min SDK constraint #44144

@kwalrath

Description

@kwalrath

If you try to run dart migrate when your minimum SDK constraint is 2.12+, you get confusing analysis errors. Instead, you should get a message like this:

This package is opted into null safety, but it has null safety errors.
Try using a lower minimum SDK constraint.
More information: https://dart.dev/go/null-safety-migration

Here's the output of dart --version:

Dart SDK version: 2.12.0-31.0.dev (dev) (Mon Nov 9 16:07:01 2020 -0800) on "macos_x64"

Details

Migrating a very simple package, I updated my minimum SDK to my Dart version (flutter master channel's dart version, 2.12.0-31.0.dev) so I could get null-safe dependencies (pedantic & test). dart pub outdated --mode=null-safety was happy. But when I tried dart migrate, it warned me about analysis issues:

$ dart migrate
Migrating <path/to>/examples/util

See https://dart.dev/go/null-safety-migration for a migration guide.

Analyzing project...
[----------------------------------------------------------------------------------------/]
3 analysis issues found:
  error • An expression whose value can be 'null' must be null-checked before it can be dereferenced at lib/dart_version.dart:6:15 • (unchecked_use_of_nullable_value)
  error • The argument type 'String?' can't be assigned to the parameter type 'String' at lib/dart_version.dart:6:15 • (argument_type_not_assignable)
  error • A value of type 'Null' can't be returned from function 'ellipsis' because it has a return type of 'T' at lib/ellipsis.dart:2:20 • (return_of_invalid_type)

Note: analysis errors will result in erroneous migration suggestions.

Please fix the analysis issues (or, force generation of migration suggestions by re-running with --ignore-errors).

Metadata

Metadata

Assignees

Labels

P1A high priority bug; for example, a single project is unusable or has many test failuresarea-migration (deprecated)Deprecated: this label is no longer actively used (was: issues with the `dart migrate` tool).

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions