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

Dart migration failed on charted package #47669

Closed
irfantusneem opened this issue Nov 11, 2021 · 1 comment
Closed

Dart migration failed on charted package #47669

irfantusneem opened this issue Nov 11, 2021 · 1 comment
Assignees
Labels
area-migration (deprecated) Deprecated: this label is no longer actively used (was: issues with the `dart migrate` tool).

Comments

@irfantusneem
Copy link

Thank you for taking the time to file an issue!

Getting unhandled exception from the tool.

Aborting migration due to an exception. This most likely is due to a
bug in the migration tool. Please consider filing a bug report at:

https://github.com/dart-lang/sdk/issues/new
Please include the SDK version (2.15.408796515-edge+google3-v2) in your bug report.

To attempt to perform migration anyway, you may re-run with
--ignore-exceptions.

Exception details:

Bad state: Unrelated types: class bool and abstract class Scale<TDomain extends Comparable*, TRange> at offset 3376 in /google/src/cloud/irfan/nullsafety/google3/third_party/dart/charted/lib/charts/behaviors/area_marker.dart (scale.scale(value))

#0 DecoratedClassHierarchy.getDecoratedSupertype (package:nnbd_migration/src/decorated_class_hierarchy.dart:67:10)
#1 DecoratedClassHierarchy.asInstanceOf (package:nnbd_migration/src/decorated_class_hierarchy.dart:38:18)
#2 EdgeBuilder.getOrComputeElementType (package:nnbd_migration/src/edge_builder.dart:274:16)
#3 EdgeBuilder.visitMethodInvocation (package:nnbd_migration/src/edge_builder.dart:1370:20)
#4 MethodInvocationImpl.accept (package:analyzer/src/dart/ast/ast.dart:7269:50)
#5 EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2307:24)
#6 EdgeBuilder._handleAssignment (package:nnbd_migration/src/edge_builder.dart:2422:20)
#7 EdgeBuilder.visitAsExpression (package:nnbd_migration/src/edge_builder.dart:409:5)
#8 AsExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:457:50)
#9 EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2307:24)
#10 EdgeBuilder._handleAssignment (package:nnbd_migration/src/edge_builder.dart:2422:20)
#11 EdgeBuilder.visitVariableDeclarationList (package:nnbd_migration/src/edge_builder.dart:2006:11)
#12 VariableDeclarationListImpl.accept (package:analyzer/src/dart/ast/ast.dart:10825:15)
#13 EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2307:24)
#14 EdgeBuilder.visitNode (package:nnbd_migration/src/edge_builder.dart:1503:9)
#15 GeneralizingAstVisitor.visitStatement (package:analyzer/dart/ast/visitor.dart:548:40)
#16 GeneralizingAstVisitor.visitVariableDeclarationStatement (package:analyzer/dart/ast/visitor.dart:624:7)
#17 VariableDeclarationStatementImpl.accept (package:analyzer/src/dart/ast/ast.dart:10874:15)
#18 EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2307:24)
#19 EdgeBuilder.visitNode (package:nnbd_migration/src/edge_builder.dart:1503:9)
#20 GeneralizingAstVisitor.visitStatement (package:analyzer/dart/ast/visitor.dart:548:40)
#21 GeneralizingAstVisitor.visitBlock (package:analyzer/dart/ast/visitor.dart:165:32)
#22 BlockImpl.accept (package:analyzer/src/dart/ast/ast.dart:1046:50)
#23 EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2307:24)
#24 EdgeBuilder.visitNode (package:nnbd_migration/src/edge_builder.dart:1503:9)
#25 GeneralizingAstVisitor.visitFunctionBody (package:analyzer/dart/ast/visitor.dart:330:46)
#26 GeneralizingAstVisitor.visitBlockFunctionBody (package:analyzer/dart/ast/visitor.dart:168:56)
#27 BlockFunctionBodyImpl.accept (package:analyzer/src/dart/ast/ast.dart:1001:50)
#28 EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2307:24)
#29 EdgeBuilder._handleExecutableDeclaration (package:nnbd_migration/src/edge_builder.dart:2605:7)
#30 EdgeBuilder.visitMethodDeclaration (package:nnbd_migration/src/edge_builder.dart:1329:5)
#31 MethodDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:7122:50)
#32 EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2307:24)
#33 EdgeBuilder._dispatchList (package:nnbd_migration/src/edge_builder.dart:2325:7)
#34 EdgeBuilder.visitClassOrMixinOrExtensionDeclaration (package:nnbd_migration/src/edge_builder.dart:676:7)
#35 EdgeBuilder.visitClassDeclaration (package:nnbd_migration/src/edge_builder.dart:643:5)
#36 ClassDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:1487:50)
#37 EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2307:24)
#38 EdgeBuilder.visitNode (package:nnbd_migration/src/edge_builder.dart:1503:9)
#39 GeneralizingAstVisitor.visitCompilationUnit (package:analyzer/dart/ast/visitor.dart:202:52)
#40 CompletenessTracker.visitCompilationUnit. (package:nnbd_migration/src/utilities/completeness_tracker.dart:52:24)
#41 PermissiveModeVisitor.reportExceptionsIfPermissive (package:nnbd_migration/src/utilities/permissive_mode.dart:26:24)
#42 CompletenessTracker.visitCompilationUnit (package:nnbd_migration/src/utilities/completeness_tracker.dart:43:5)
#43 CompilationUnitImpl.accept (package:analyzer/src/dart/ast/ast.dart:2088:50)
#44 NullabilityMigrationImpl.processInput (package:nnbd_migration/src/nullability_migration_impl.dart:231:12)
#45 NonNullableFix.processUnit (package:nnbd_migration/src/front_end/non_nullable_fix.dart:164:16)
#46 _FixCodeProcessor.runLaterPhases. (package:nnbd_migration/migration_cli.dart:1092:20)
#47 _FixCodeProcessor.runLaterPhases. (package:nnbd_migration/migration_cli.dart:1090:28)
#48 _FixCodeProcessor.processResources (package:nnbd_migration/migration_cli.dart:1024:26)

#49 _FixCodeProcessor.runLaterPhases (package:nnbd_migration/migration_cli.dart:1090:5)

#50 MigrationCliRunner.run (package:nnbd_migration/migration_cli.dart:697:24)

#51 startMigrationTool (package:dart.null_safety.migration/src/migration_runner.dart:301:5)

#52 main (package:dart.null_safety.migration/migration.dart:57:3)

#53 main (google3:///dart/null_safety/migration/bin/migration.dart:7:5)

Unhandled error: Instance of 'MigrationExit'
#0 MigrationCliRunner.onException (package:nnbd_migration/migration_cli.dart:585:9)
#1 NullabilityMigrationAdapter.reportException (package:nnbd_migration/src/front_end/non_nullable_fix.dart:550:21)
#2 PermissiveModeVisitor.reportExceptionsIfPermissive (package:nnbd_migration/src/utilities/permissive_mode.dart:28:19)
#3 CompletenessTracker.visitCompilationUnit (package:nnbd_migration/src/utilities/completeness_tracker.dart:43:5)
#4 CompilationUnitImpl.accept (package:analyzer/src/dart/ast/ast.dart:2088:50)
#5 NullabilityMigrationImpl.processInput (package:nnbd_migration/src/nullability_migration_impl.dart:231:12)
#6 NonNullableFix.processUnit (package:nnbd_migration/src/front_end/non_nullable_fix.dart:164:16)
#7 _FixCodeProcessor.runLaterPhases. (package:nnbd_migration/migration_cli.dart:1092:20)
#8 _FixCodeProcessor.runLaterPhases. (package:nnbd_migration/migration_cli.dart:1090:28)
#9 _FixCodeProcessor.processResources (package:nnbd_migration/migration_cli.dart:1024:26)

#10 _FixCodeProcessor.runLaterPhases (package:nnbd_migration/migration_cli.dart:1090:5)

#11 MigrationCliRunner.run (package:nnbd_migration/migration_cli.dart:697:24)

#12 startMigrationTool (package:dart.null_safety.migration/src/migration_runner.dart:301:5)

#13 main (package:dart.null_safety.migration/migration.dart:57:3)

#14 main (google3:///dart/null_safety/migration/bin/migration.dart:7:5)

Add comment
Add a comment.
CC Me
Markdown

@lrhn lrhn added the area-migration (deprecated) Deprecated: this label is no longer actively used (was: issues with the `dart migrate` tool). label Nov 11, 2021
@stereotype441
Copy link
Member

This is a particularly interesting (and hopefully rare) case. What's happening is that the source code has a statement like this:

class C<T> {
  T m() { ... }
}
f() {
  var x = /* some expression of type `bool` */,
      y = /* some expression of type `C<U>` for some `U`, e.g. `C<String>`> */,
      z = y.m();
}

The migration tool is trying to figure out the type of the expression y.m(), and to do that it needs to take the type parameter from the type of y (U in this example) and substitute it into the type of C.m. But when it tries to get the type parameter from the type of y, it gets confused and picks up the type of x instead (bool). Since that type doesn't have any type parameters, it gets confused and crashes.

I'm working on a fix.

@stereotype441 stereotype441 self-assigned this Nov 11, 2021
copybara-service bot pushed a commit that referenced this issue Nov 11, 2021
…le variables.

This fix addresses the case where a variable declaration statement
declares multiple variables with different types; previously, we were
applying the type of the first variable to all the variables, leading
to possible crashes.

There are still some other issues with variable declaration statements
that declare multiple variables; I'll address them in follow-up CLs.

Bug: #47669
Change-Id: Iba82ef5ccc0b22382f30bf5a6ed391f4874f7443
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220042
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-migration (deprecated) Deprecated: this label is no longer actively used (was: issues with the `dart migrate` tool).
Projects
None yet
Development

No branches or pull requests

3 participants