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

CFE crashes computing upper bounds of some generic function types #56420

Closed
chloestefantsova opened this issue Aug 9, 2024 · 1 comment
Closed
Assignees
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. cfe-crashes Crashes in the CFE

Comments

@chloestefantsova
Copy link
Contributor

chloestefantsova commented Aug 9, 2024

The CFE crashes compiling the following code:

class A<X1 extends B, X2 extends B> {}
class B {}
A<Y1, Y2> Function<Y1 extends B, Y2 extends B>() f1 = <Y1 extends B, Y2 extends B>() => new A<Y1, Y2>();
A<Z2, Z1> Function<Z1 extends B, Z2 extends B>() f2 = <Z1 extends B, Z2 extends B>() => new A<Z2, Z1>();
test(bool b) {
  var x = b ? f1 : f2;
}

The top of the stack is as follows:

Crash when compiling file:///tmp/qwerty2.dart at character offset 271:
type 'StructuralParameterType' is not a subtype of type 'TypeDeclarationType' in type cast

#0      StandardBounds.getNullabilityAwareStandardUpperBoundInternal (package:kernel/src/standard_bounds.dart:871:15)
#1      TypeSchemaStandardBounds.getNullabilityAwareStandardUpperBoundInternal (package:front_end/src/type_inference/standard_bounds.dart:54:18)
#2      StandardBounds._getNullabilityAwareStandardUpperBound (package:kernel/src/standard_bounds.dart:566:12)
#3      StandardBounds.getNullabilityAwareStandardUpperBoundInternal (package:kernel/src/standard_bounds.dart:848:30)
#4      TypeSchemaStandardBounds.getNullabilityAwareStandardUpperBoundInternal (package:front_end/src/type_inference/standard_bounds.dart:54:18)
#5      StandardBounds._getNullabilityAwareStandardUpperBound (package:kernel/src/standard_bounds.dart:566:12)
#6      StandardBounds._getNullabilityAwareFunctionStandardUpperBound (package:kernel/src/standard_bounds.dart:1347:27)
#7      StandardBounds.getNullabilityAwareStandardUpperBoundInternal (package:kernel/src/standard_bounds.dart:710:16)
#8      TypeSchemaStandardBounds.getNullabilityAwareStandardUpperBoundInternal (package:front_end/src/type_inference/standard_bounds.dart:54:18)
#9      StandardBounds._getNullabilityAwareStandardUpperBound (package:kernel/src/standard_bounds.dart:566:12)
#10     StandardBounds.getStandardUpperBound (package:kernel/src/standard_bounds.dart:558:12)
#11     InferenceVisitorImpl.visitConditionalExpression (package:front_end/src/type_inference/inference_visitor.dart:1085:40)
#12     ConditionalExpression.accept1 (package:kernel/ast.dart:6931:9)
#13     InferenceVisitorImpl._inferExpression (package:front_end/src/type_inference/inference_visitor.dart:292:27)
#14     InferenceVisitorImpl.inferExpression (package:front_end/src/type_inference/inference_visitor.dart:326:40)
#15     InferenceVisitorImpl.visitVariableDeclaration (package:front_end/src/type_inference/inference_visitor.dart:9377:11)
#16     VariableDeclaration.accept (package:kernel/ast.dart:10742:43)
#17     InferenceVisitorImpl.inferStatement (package:front_end/src/type_inference/inference_visitor.dart:275:26)
#18     InferenceVisitorImpl._visitStatements (package:front_end/src/type_inference/inference_visitor.dart:924:50)
#19     InferenceVisitorImpl.visitBlock (package:front_end/src/type_inference/inference_visitor.dart:945:31)
#20     Block.accept (package:kernel/ast.dart:9170:43)
#21     InferenceVisitorImpl.inferStatement (package:front_end/src/type_inference/inference_visitor.dart:275:26)
#22     TypeInferrerImpl.inferFunctionBody (package:front_end/src/type_inference/type_inferrer.dart:184:17)
#23     BodyBuilder.finishFunction (package:front_end/src/kernel/body_builder.dart:1254:43)
#24     DietListener.buildFunctionBody (package:front_end/src/source/diet_listener.dart:1329:19)
#25     DietListener.endTopLevelMethod (package:front_end/src/source/diet_listener.dart:380:5)
#26     Parser.parseTopLevelMethod (package:_fe_analyzer_shared/src/parser/parser_impl.dart:3898:14)
#27     Parser.parseTopLevelMemberImpl (package:_fe_analyzer_shared/src/parser/parser_impl.dart:3630:14)
#28     Parser.parseTopLevelDeclarationImpl (package:_fe_analyzer_shared/src/parser/parser_impl.dart:627:14)
#29     Parser.parseUnit (package:_fe_analyzer_shared/src/parser/parser_impl.dart:420:15)
#30     SourceLoader.buildBody (package:front_end/src/source/source_loader.dart:1311:12)
<asynchronous suspension>
#31     SourceLoader.buildBodies (package:front_end/src/source/source_loader.dart:810:7)
<asynchronous suspension>
#32     KernelTarget.buildComponent.<anonymous closure> (package:front_end/src/kernel/kernel_target.dart:734:7)
<asynchronous suspension>
#33     withCrashReporting (package:front_end/src/base/crash.dart:138:12)
<asynchronous suspension>
#34     KernelTarget.buildComponent (package:front_end/src/kernel/kernel_target.dart:711:12)
<asynchronous suspension>
@chloestefantsova chloestefantsova self-assigned this Aug 9, 2024
@chloestefantsova chloestefantsova added area-front-end Use area-front-end for front end / CFE / kernel format related issues. cfe-crashes Crashes in the CFE labels Aug 9, 2024
@chloestefantsova
Copy link
Contributor Author

I'm working on a fix at https://dart-review.googlesource.com/c/sdk/+/379800

copybara-service bot pushed a commit that referenced this issue Aug 13, 2024
Closes #56420

Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/379800
Cherry-pick-request: #56457
Change-Id: Ib82efe4cd0da9f406f87d2c23f77f3f2f86147ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380240
Reviewed-by: Johnni Winther <[email protected]>
Commit-Queue: Kevin Chisholm <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. cfe-crashes Crashes in the CFE
Projects
None yet
Development

No branches or pull requests

1 participant