Skip to content

Compiler Crash on record interaction with iterable/spread operator and for loop #53092

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
AngryVelociraptor opened this issue Aug 2, 2023 · 0 comments
Assignees
Labels
legacy-area-front-end Legacy: Use area-dart-model instead. P2 A bug or feature request we're likely to work on

Comments

@AngryVelociraptor
Copy link

When attempting to compile the following code, the dart compiler crashes.
This was reproduced on dartpad on Dart version 3.0.5 and 3.12.0

final t = {
  ...<String, String>{}.entries.map<(String, String)>((e) => (e.key, e.value))
};

compiles() {
  for (final (var1, var2) in t) {}
}

doesntCompile() async {
  for (final (var1, var2) in {
    ...<String, String>{}.entries.map<(String, String)>((e) => (e.key, e.value))
  }) {}
}

void main() {}

Observe that if you comment out the function doesntCompile, the code that should be equivalent successfully compiles.

Dartpad error message/traceback

Internal Error: The compiler crashed when compiling this element.

The compiler is broken.

When compiling the above element, the compiler crashed. It is not
possible to tell if this is caused by a problem in your program or
not. Regardless, the compiler should not crash.

The Dart team would greatly appreciate if you would take a moment to
report this problem at http://dartbug.com/new.

Please include the following information:

* the name and version of your operating system,

* the Dart SDK build number (3.1.0-163.1.beta), and

* the entire message you see here (including the full stack trace
  below as well as the source location above).

The compiler crashed: Crash when compiling file:///tmp/dartpadIWCXSL/lib/main.dart at character offset 162:
type 'VariableDeclaration' is not a subtype of type 'VariableDeclarationImpl' of 'node'

#0      InferenceVisitorImpl.visitVariableDeclaration (package:front_end/src/fasta/type_inference/inference_visitor.dart)
#1      VariableDeclaration.accept (package:kernel/ast.dart:11447:43)
#2      InferenceVisitorImpl.inferStatement (package:front_end/src/fasta/type_inference/inference_visitor.dart:238:26)
#3      InferenceVisitorImpl._visitStatements (package:front_end/src/fasta/type_inference/inference_visitor.dart:848:50)
#4      InferenceVisitorImpl.visitBlock (package:front_end/src/fasta/type_inference/inference_visitor.dart:869:31)
#5      Block.accept (package:kernel/ast.dart:9788:43)
#6      InferenceVisitorImpl.inferStatement (package:front_end/src/fasta/type_inference/inference_visitor.dart:238:26)
#7      InferenceVisitorImpl.visitBlockExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:388:43)
#8      BlockExpression.accept1 (package:kernel/ast.dart:9369:9)
#9      InferenceVisitorImpl._inferExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:260:27)
#10     InferenceVisitorImpl.inferExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:295:40)
#11     InferenceVisitorImpl.inferForInIterable (package:front_end/src/fasta/type_inference/inference_visitor.dart:1494:9)
#12     InferenceVisitorImpl._handlePatternForIn (package:front_end/src/fasta/type_inference/inference_visitor.dart:1621:9)
#13     InferenceVisitorImpl.handleForInWithoutVariable (package:front_end/src/fasta/type_inference/inference_visitor.dart:1645:14)
#14     InferenceVisitorImpl.visitForInStatementWithSynthesizedVariable (package:front_end/src/fasta/type_inference/inference_visitor.dart:1685:26)
#15     ForInStatementWithSynthesizedVariable.acceptInference (package:front_end/src/fasta/kernel/internal_ast.dart:270:20)
#16     InferenceVisitorImpl.inferStatement (package:front_end/src/fasta/type_inference/inference_visitor.dart:236:26)
#17     InferenceVisitorImpl._visitStatements (package:front_end/src/fasta/type_inference/inference_visitor.dart:848:50)
#18     InferenceVisitorImpl.visitBlock (package:front_end/src/fasta/type_inference/inference_visitor.dart:869:31)
#19     Block.accept (package:kernel/ast.dart:9788:43)
#20     InferenceVisitorImpl.inferStatement (package:front_end/src/fasta/type_inference/inference_visitor.dart:238:26)
#21     TypeInferrerImpl.inferFunctionBody (package:front_end/src/fasta/type_inference/type_inferrer.dart:202:17)
#22     BodyBuilder.finishFunction (package:front_end/src/fasta/kernel/body_builder.dart:1263:43)
#23     DietListener.buildFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:1137:19)
#24     DietListener.endTopLevelMethod (package:front_end/src/fasta/source/diet_listener.dart:387:5)
#25     Parser.parseTopLevelMethod (package:_fe_analyzer_shared/src/parser/parser_impl.dart:3757:14)
#26     Parser.parseTopLevelMemberImpl (package:_fe_analyzer_shared/src/parser/parser_impl.dart:3514:14)
#27     Parser.parseTopLevelDeclarationImpl (package:_fe_analyzer_shared/src/parser/parser_impl.dart:624:14)
#28     Parser.parseUnit (package:_fe_analyzer_shared/src/parser/parser_impl.dart:414:15)
#29     SourceLoader.buildBody (package:front_end/src/fasta/source/source_loader.dart:1266:12)
<asynchronous suspension>
#30     SourceLoader.buildBodies (package:front_end/src/fasta/source/source_loader.dart:672:7)
<asynchronous suspension>
#31     KernelTarget.buildComponent.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:609:7)
<asynchronous suspension>
#32     withCrashReporting (package:front_end/src/fasta/crash.dart:136:12)
<asynchronous suspension>
#33     KernelTarget.buildComponent (package:front_end/src/fasta/kernel/kernel_target.dart:590:12)
<asynchronous suspension>
#34     _buildInternal (package:front_end/src/kernel_generator_impl.dart:208:19)
<asynchronous suspension>
#35     withCrashReporting (package:front_end/src/fasta/crash.dart:136:12)
<asynchronous suspension>
#36     compile.<anonymous closure> (package:front_end/src/api_unstable/dart2js.dart:200:37)
<asynchronous suspension>
#37     compile (package:front_end/src/api_unstable/dart2js.dart:198:36)
<asynchronous suspension>
#38     _loadFromSource (package:compiler/src/phase/load_kernel.dart:303:29)
<asynchronous suspension>
#39     run (package:compiler/src/phase/load_kernel.dart:404:36)
<asynchronous suspension>
#40     Compiler.loadKernel (package:compiler/src/compiler.dart:388:9)
<asynchronous suspension>
#41     Compiler.produceKernel (package:compiler/src/compiler.dart:395:36)
<asynchronous suspension>
#42     Compiler.runSequentialPhases (package:compiler/src/compiler.dart:711:20)
<asynchronous suspension>
#43     Compiler.runInternal.<anonymous closure> (package:compiler/src/compiler.dart:311:7)
<asynchronous suspension>
#44     Compiler.runInternal (package:compiler/src/compiler.dart:310:5)
<asynchronous suspension>
#45     Compiler.run.<anonymous closure> (package:compiler/src/compiler.dart:231:11)
<asynchronous suspension>
#46     main (package:compiler/src/dart2js.dart:1241:3)
<asynchronous suspension>

@mraleph mraleph added the legacy-area-front-end Legacy: Use area-dart-model instead. label Aug 3, 2023
@johnniwinther johnniwinther added the P2 A bug or feature request we're likely to work on label Aug 3, 2023
copybara-service bot pushed a commit that referenced this issue Aug 17, 2023
This is a follow-up to https://dart-review.googlesource.com/c/sdk/+/321141

Change-Id: I450592e2c9063cd565bcf26f8ab00c2421911486
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321460
Reviewed-by: Johnni Winther <[email protected]>
Commit-Queue: Chloe Stefantsova <[email protected]>
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. P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

4 participants