Description
This is a minified version of something I spotted in a real program, enter the following in https://dartpad.dev
void main() {
for (final (i, item) in [...[]].indexed) {}
}
You'll get a compiler crash,
Internal Error: The compiler crashed when compiling this element.
The compiler is broken.
Crash log
Error compiling to JavaScript: lib/main.dart: 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), 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/dartpadNIFUFT/lib/main.dart at character offset 10:
type 'VariableDeclaration' is not a subtype of type 'VariableDeclarationImpl' of 'node'
#0 InferenceVisitorImpl.visitVariableDeclaration (package:front_end/src/fasta/type_inference/inference_visitor.dart:8631:41)
#1 VariableDeclaration.accept (package:kernel/ast.dart:10709:43)
#2 InferenceVisitorImpl.inferStatement (package:front_end/src/fasta/type_inference/inference_visitor.dart:242:26)
#3 InferenceVisitorImpl._visitStatements (package:front_end/src/fasta/type_inference/inference_visitor.dart:847:50)
#4 InferenceVisitorImpl.visitBlock (package:front_end/src/fasta/type_inference/inference_visitor.dart:868:31)
#5 Block.accept (package:kernel/ast.dart:9173:43)
#6 InferenceVisitorImpl.inferStatement (package:front_end/src/fasta/type_inference/inference_visitor.dart:242:26)
#7 InferenceVisitorImpl.visitBlockExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:384:43)
#8 BlockExpression.accept1 (package:kernel/ast.dart:8778:9)
#9 InferenceVisitorImpl._inferExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:259:27)
#10 InferenceVisitorImpl.inferExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:291:40)
#11 InferenceVisitorBase._inferInvocation.inferArgument (package:front_end/src/fasta/type_inference/inference_visitor_base.dart:1872:22)
#12 InferenceVisitorBase._inferInvocation (package:front_end/src/fasta/type_inference/inference_visitor_base.dart:1936:44)
#13 InferenceVisitorBase.inferInvocation (package:front_end/src/fasta/type_inference/inference_visitor_base.dart:1627:12)
#14 InferenceVisitorImpl.visitStaticInvocation (package:front_end/src/fasta/type_inference/inference_visitor.dart:8065:40)
#15 StaticInvocation.accept1 (package:kernel/ast.dart:6582:9)
#16 InferenceVisitorImpl._inferExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:259:27)
#17 InferenceVisitorImpl.inferExpression (package:front_end/src/fasta/type_inference/inference_visitor.dart:291:40)
#18 InferenceVisitorImpl.inferForInIterable (package:front_end/src/fasta/type_inference/inference_visitor.dart:1506:9)
#19 InferenceVisitorImpl._handlePatternForIn (package:front_end/src/fasta/type_inference/inference_visitor.dart:1630:9)
#20 InferenceVisitorImpl.handleForInWithoutVariable (package:front_end/src/fasta/type_inference/inference_visitor.dart:1654:14)
#21 InferenceVisitorImpl.visitForInStatementWithSynthesizedVariable (package:front_end/src/fasta/type_inference/inference_visitor.dart:1694:26)
#22 ForInStatementWithSynthesizedVariable.acceptInference (package:front_end/src/fasta/kernel/internal_ast.dart:266:20)
#23 InferenceVisitorImpl.inferStatement (package:front_end/src/fasta/type_inference/inference_visitor.dart:240:26)
#24 InferenceVisitorImpl._visitStatements (package:front_end/src/fasta/type_inference/inference_visitor.dart:847:50)
#25 InferenceVisitorImpl.visitBlock (package:front_end/src/fasta/type_inference/inference_visitor.dart:868:31)
#26 Block.accept (package:kernel/ast.dart:9173:43)
#27 InferenceVisitorImpl.inferStatement (package:front_end/src/fasta/type_inference/inference_visitor.dart:242:26)
#28 TypeInferrerImpl.inferFunctionBody (package:front_end/src/fasta/type_inference/type_inferrer.dart:198:17)
#29 BodyBuilder.finishFunction (package:front_end/src/fasta/kernel/body_builder.dart:1254:43)
#30 DietListener.buildFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:1133:19)
#31 DietListener.endTopLevelMethod (package:front_end/src/fasta/source/diet_listener.dart:387:5)
#32 Parser.parseTopLevelMethod (package:_fe_analyzer_shared/src/parser/parser_impl.dart:3747:14)
#33 Parser.parseTopLevelMemberImpl (package:_fe_analyzer_shared/src/parser/parser_impl.dart:3504:14)
#34 Parser.parseTopLevelDeclarationImpl (package:_fe_analyzer_shared/src/parser/parser_impl.dart:624:14)
#35 Parser.parseUnit (package:_fe_analyzer_shared/src/parser/parser_impl.dart:414:15)
#36 SourceLoader.buildBody (package:front_end/src/fasta/source/source_loader.dart:1247:12)
#37 SourceLoader.buildBodies (package:front_end/src/fasta/source/source_loader.dart:669:7)
#38 KernelTarget.buildComponent. (package:front_end/src/fasta/kernel/kernel_target.dart:607:7)
#39 withCrashReporting (package:front_end/src/fasta/crash.dart:133:12)
#40 KernelTarget.buildComponent (package:front_end/src/fasta/kernel/kernel_target.dart:588:12)
#41 _buildInternal (package:front_end/src/kernel_generator_impl.dart:210:19)
#42 withCrashReporting (package:front_end/src/fasta/crash.dart:133:12)
#43 compile. (package:front_end/src/api_unstable/dart2js.dart:198:37)
#44 compile (package:front_end/src/api_unstable/dart2js.dart:196:36)
#45 _loadFromSource (package:compiler/src/phase/load_kernel.dart:304:29)
#46 run (package:compiler/src/phase/load_kernel.dart:417:36)
#47 Compiler.loadKernel (package:compiler/src/compiler.dart:388:9)
#48 Compiler.produceKernel (package:compiler/src/compiler.dart:395:36)
#49 Compiler.runSequentialPhases (package:compiler/src/compiler.dart:711:20)
#50 Compiler.runInternal. (package:compiler/src/compiler.dart:311:7)
#51 Compiler.runInternal (package:compiler/src/compiler.dart:310:5)
#52 Compiler.run. (package:compiler/src/compiler.dart:231:11)
#53 main (package:compiler/src/dart2js.dart:1241:3)