Skip to content

Compiler crashing when using pattern in collection-for #51376

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

Closed
mmcdon20 opened this issue Feb 11, 2023 · 3 comments
Closed

Compiler crashing when using pattern in collection-for #51376

mmcdon20 opened this issue Feb 11, 2023 · 3 comments
Labels
legacy-area-front-end Legacy: Use area-dart-model instead.

Comments

@mmcdon20
Copy link

Likely just due to not being implemented yet, but I am trying out the patterns and records features and came across a compiler crash.

Using Dart SDK version: 3.0.0-229.0.dev (dev) (Fri Feb 10 20:38:38 2023 -0800) on "windows_x64".

Take this example

void main() {
  print(left([(1,2), (3, 4)])); // expecting [1, 3]
}

List<A> left<A, B>(List<(A, B)> pairs) => [for (var (a, _) in pairs) a];

compiled with dart --enable-experiment=records,patterns bin/example.dart

Crash when compiling file:///C:/Users/mmcdo/Documents/projects/project/bin/example.dart at character offset 110:
Null check operator used on a null value

#0      InferenceVisitorImpl.inferElement (package:front_end/src/fasta/type_inference/inference_visitor.dart:2262:40)       
#1      InferenceVisitorImpl.visitListLiteral (package:front_end/src/fasta/type_inference/inference_visitor.dart:2382:42)   
#2      ListLiteral.accept1 (package:kernel/ast.dart:8684:9)
#3      InferenceVisitorImpl._inferExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:263:27)    
#4      InferenceVisitorImpl.inferExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:298:40)     
#5      InferenceVisitorImpl.visitReturnStatement (package:front_end/src/fasta/type_inference/inference_visitor.dart:7281:11)
#6      ReturnStatement.accept (package:kernel/ast.dart:10766:43)
#7      InferenceVisitorImpl.inferStatement (package:front_end/src/fasta/type_inference/inference_visitor.dart:241:26)      
#8      TypeInferrerImpl.inferFunctionBody (package:front_end/src/fasta/type_inference/type_inferrer.dart:196:17)
#9      BodyBuilder.finishFunction (package:front_end/src/fasta/kernel/body_builder.dart:1344:43)
#10     DietListener.buildFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:1123:19)
#11     DietListener.endTopLevelMethod (package:front_end/src/fasta/source/diet_listener.dart:376:5)
#12     Parser.parseTopLevelMethod (package:_fe_analyzer_shared/src/parser/parser_impl.dart:3682:14)
#13     Parser.parseTopLevelMemberImpl (package:_fe_analyzer_shared/src/parser/parser_impl.dart:3424:14)
#14     Parser.parseTopLevelDeclarationImpl (package:_fe_analyzer_shared/src/parser/parser_impl.dart:606:14)
#15     Parser.parseUnit (package:_fe_analyzer_shared/src/parser/parser_impl.dart:403:15)
#16     SourceLoader.buildBody (package:front_end/src/fasta/source/source_loader.dart:1267:12)
<asynchronous suspension>
#17     SourceLoader.buildBodies (package:front_end/src/fasta/source/source_loader.dart:676:7)
<asynchronous suspension>
#18     KernelTarget.buildComponent.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:611:7)       
<asynchronous suspension>
#19     withCrashReporting (package:front_end/src/fasta/crash.dart:136:12)
<asynchronous suspension>
#20     _buildInternal (package:front_end/src/kernel_generator_impl.dart:206:19)
<asynchronous suspension>
#21     withCrashReporting (package:front_end/src/fasta/crash.dart:136:12)
<asynchronous suspension>
#22     generateKernel.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:48:12)
<asynchronous suspension>
#23     generateKernel (package:front_end/src/kernel_generator_impl.dart:47:10)
<asynchronous suspension>
#24     kernelForModule (package:front_end/src/api_prototype/kernel_generator.dart:100:11)
<asynchronous suspension>
#25     SingleShotCompilerWrapper.compileInternal (file:///C:/b/s/w/ir/x/w/sdk/pkg/vm/bin/kernel_service.dart:407:11)       
<asynchronous suspension>
#26     Compiler.compile.<anonymous closure> (file:///C:/b/s/w/ir/x/w/sdk/pkg/vm/bin/kernel_service.dart:215:45)
<asynchronous suspension>
#27     _processLoadRequest (file:///C:/b/s/w/ir/x/w/sdk/pkg/vm/bin/kernel_service.dart:889:37)
<asynchronous suspension>
@lrhn lrhn added the legacy-area-front-end Legacy: Use area-dart-model instead. label Feb 11, 2023
@mmcdon20

This comment was marked as duplicate.

@mmcdon20

This comment was marked as duplicate.

@asashour
Copy link
Contributor

  • sdk/282602 for the OP crash
  • Please provide a test case for the crash of collection-if pattern, in a separate issue if the stacktrace is different.
  • I guess the last point should also be better in a separate issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy-area-front-end Legacy: Use area-dart-model instead.
Projects
None yet
Development

No branches or pull requests

3 participants