Closed pingbird closed 4 years ago
The following code crashes the compiler on all platforms, including dartpad:
extension <A, B> on B Function(A input) { C Function(A) operator &<C>(C Function(B) f) => (input) => f(this.call(input)); } void main() { var f = (a){} & (a){}; }
Error compiling to JavaScript: 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 (2.7.1), 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/dartpadTOIIEY/main.dart, at character offset 136: Invalid argument(s): Iterables do not have same length. #0 MapBase._fillMapWithIterables (dart:collection/maps.dart:87:7) #1 new LinkedHashMap.fromIterables (dart:collection/linked_hash_map.dart:129:13) #2 Substitution.fromPairs (package:kernel/type_algebra.dart:240:13) #3 TypeInferrerImpl.getReturnType (package:front_end/src/fasta/type_inference/type_inferrer.dart:1096:56) #4 InferenceVisitor._computeBinaryExpression (package:front_end/src/fasta/kernel/inference_visitor.dart:3429:36) #5 InferenceVisitor.visitBinary (package:front_end/src/fasta/kernel/inference_visitor.dart:5283:12) #6 BinaryExpression.acceptInference (package:front_end/src/fasta/kernel/internal_ast.dart:2790:20) #7 TypeInferrerImpl.inferExpression (package:front_end/src/fasta/type_inference/type_inferrer.dart:1475:27) #8 InferenceVisitor.visitVariableDeclaration (package:front_end/src/fasta/kernel/inference_visitor.dart:5031:36) #9 VariableDeclaration.accept (package:kernel/ast.dart:5292:43) #10 TypeInferrerImpl.inferStatement (package:front_end/src/fasta/type_inference/type_inferrer.dart:2646:22) #11 InferenceVisitor._visitStatements (package:front_end/src/fasta/kernel/inference_visitor.dart:306:20) #12 InferenceVisitor.visitBlock (package:front_end/src/fasta/kernel/inference_visitor.dart:327:30) #13 Block.accept (package:kernel/ast.dart:4519:43) #14 TypeInferrerImpl.inferStatement (package:front_end/src/fasta/type_inference/type_inferrer.dart:2646:22) #15 TypeInferrerImpl.inferFunctionBody (package:front_end/src/fasta/type_inference/type_inferrer.dart:1525:39) #16 BodyBuilder.finishFunction (package:front_end/src/fasta/kernel/body_builder.dart:910:28) #17 DietListener.listenerFinishFunction (package:front_end/src/fasta/source/diet_listener.dart:904:14) #18 DietListener.buildFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:937:7) #19 DietListener.endTopLevelMethod (package:front_end/src/fasta/source/diet_listener.dart:348:5) #20 Parser.parseTopLevelMethod (package:_fe_analyzer_shared/src/parser/parser_impl.dart:2518:14) #21 Parser.parseTopLevelMemberImpl (package:_fe_analyzer_shared/src/parser/parser_impl.dart:2372:14) #22 Parser.parseTopLevelDeclarationImpl (package:_fe_analyzer_shared/src/parser/parser_impl.dart:495:14) #23 Parser.parseUnit (package:_fe_analyzer_shared/src/parser/parser_impl.dart:352:15) #24 SourceLoader.buildBody (package:front_end/src/fasta/source/source_loader.dart:312:14) <asynchronous suspension> #25 Loader.buildBodies (package:front_end/src/fasta/loader.dart:243:15) #26 KernelTarget.buildComponent.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:307:20) #27 withCrashReporting (package:front_end/src/fasta/crash.dart:122:24) #28 KernelTarget.buildComponent (package:front_end/src/fasta/kernel/kernel_target.dart:305:12) #29 generateKernelInternal.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:170:38) <asynchronous suspension> #30 withCrashReporting (package:front_end/src/fasta/crash.dart:122:24) #31 generateKernelInternal (package:front_end/src/kernel_generator_impl.dart:70:10) #32 compile.<anonymous closure> (package:front_end/src/api_unstable/dart2js.dart:173:43) #33 CompilerContext.runWithOptions.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:135:20) <asynchronous suspension> #34 CompilerContext.runInContext.<anonymous closure>.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:123:46) #35 new Future.sync (dart:async/future.dart:224:31) #36 CompilerContext.runInContext.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:123:19) #37 _rootRun (dart:async/zone.dart:1126:13) #38 _CustomZone.run (dart:async/zone.dart:1023:19) #39 _runZoned (dart:async/zone.dart:1518:10) #40 runZoned (dart:async/zone.dart:1465:12) #41 CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:122:12) #42 CompilerContext.runWithOptions (package:front_end/src/fasta/compiler_context.dart:133:10) #43 compile (package:front_end/src/api_unstable/dart2js.dart:171:57) #44 KernelLoaderTask.load.<anonymous closure> (file:///tmp/tmpRpxoJi/dart-2.7.1/dart/pkg/compiler/lib/src/kernel/loader.dart:109:27) #45 CompilerTask.measure (file:///tmp/tmpRpxoJi/dart-2.7.1/dart/pkg/compiler/lib/src/common/tasks.dart:64:51) #46 KernelLoaderTask.load (file:///tmp/tmpRpxoJi/dart-2.7.1/dart/pkg/compiler/lib/src/kernel/loader.dart:59:12) #47 Compiler.runInternal (file:///tmp/tmpRpxoJi/dart-2.7.1/dart/pkg/compiler/lib/src/compiler.dart:236:48) #48 Compiler.run.<anonymous closure>.<anonymous closure> (file:///tmp/tmpRpxoJi/dart-2.7.1/dart/pkg/compiler/lib/src/compiler.dart:210:38) #49 new Future.sync (dart:async/future.dart:224:31) #50 Compiler.run.<anonymous closure> (file:///tmp/tmpRpxoJi/dart-2.7.1/dart/pkg/compiler/lib/src/compiler.dart:210:20) #51 CompilerTask.measureSubtask (file:///tmp/tmpRpxoJi/dart-2.7.1/dart/pkg/compiler/lib/src/common/tasks.dart:179:35) #52 Compiler.run (file:///tmp/tmpRpxoJi/dart-2.7.1/dart/pkg/compiler/lib/src/compiler.dart:207:41) #53 CompilerImpl.run.<anonymous closure>.<anonymous closure> (file:///tmp/tmpRpxoJi/dart-2.7.1/dart/pkg/compiler/lib/src/apiimpl.dart:91:22) #54 _RootZone.runUnary (dart:async/zone.dart:1381:54) #55 _FutureListener.handleValue (dart:async/future_impl.dart:139:18) #56 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45) #57 Future._propagateToListeners (dart:async/future_impl.dart:709:32) #58 Future._completeWithValue (dart:async/future_impl.dart:524:5) #59 Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:554:7) #60 _microtaskLoop (dart:async/schedule_microtask.dart:43:21) #61 _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5) #62 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13) #63 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:175:5) #0 DietListener.buildFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:942:7) #1 DietListener.endTopLevelMethod (package:front_end/src/fasta/source/diet_listener.dart:348:5) #2 Parser.parseTopLevelMethod (package:_fe_analyzer_shared/src/parser/parser_impl.dart:2518:14) #3 Parser.parseTopLevelMemberImpl (package:_fe_analyzer_shared/src/parser/parser_impl.dart:2372:14) #4 Parser.parseTopLevelDeclarationImpl (package:_fe_analyzer_shared/src/parser/parser_impl.dart:495:14) #5 Parser.parseUnit (package:_fe_analyzer_shared/src/parser/parser_impl.dart:352:15) #6 SourceLoader.buildBody (package:front_end/src/fasta/source/source_loader.dart:312:14) <asynchronous suspension> #7 Loader.buildBodies (package:front_end/src/fasta/loader.dart:243:15) #8 KernelTarget.buildComponent.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:307:20) #9 withCrashReporting (package:front_end/src/fasta/crash.dart:122:24) #10 KernelTarget.buildComponent (package:front_end/src/fasta/kernel/kernel_target.dart:305:12) #11 generateKernelInternal.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:170:38) <asynchronous suspension> #12 withCrashReporting (package:front_end/src/fasta/crash.dart:122:24) #13 generateKernelInternal (package:front_end/src/kernel_generator_impl.dart:70:10) #14 compile.<anonymous closure> (package:front_end/src/api_unstable/dart2js.dart:173:43) #15 CompilerContext.runWithOptions.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:135:20) <asynchronous suspension> #16 CompilerContext.runInContext.<anonymous closure>.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:123:46) #17 new Future.sync (dart:async/future.dart:224:31) #18 CompilerContext.runInContext.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:123:19) #19 _rootRun (dart:async/zone.dart:1126:13) #20 _CustomZone.run (dart:async/zone.dart:1023:19) #21 _runZoned (dart:async/zone.dart:1518:10) #22 runZoned (dart:async/zone.dart:1465:12) #23 CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:122:12) #24 CompilerContext.runWithOptions (package:front_end/src/fasta/compiler_context.dart:133:10) #25 compile (package:front_end/src/api_unstable/dart2js.dart:171:57) #26 KernelLoaderTask.load.<anonymous closure> (file:///tmp/tmpRpxoJi/dart-2.7.1/dart/pkg/compiler/lib/src/kernel/loader.dart:109:27) #27 CompilerTask.measure (file:///tmp/tmpRpxoJi/dart-2.7.1/dart/pkg/compiler/lib/src/common/tasks.dart:64:51) #28 KernelLoaderTask.load (file:///tmp/tmpRpxoJi/dart-2.7.1/dart/pkg/compiler/lib/src/kernel/loader.dart:59:12) #29 Compiler.runInternal (file:///tmp/tmpRpxoJi/dart-2.7.1/dart/pkg/compiler/lib/src/compiler.dart:236:48) #30 Compiler.run.<anonymous closure>.<anonymous closure> (file:///tmp/tmpRpxoJi/dart-2.7.1/dart/pkg/compiler/lib/src/compiler.dart:210:38) #31 new Future.sync (dart:async/future.dart:224:31) #32 Compiler.run.<anonymous closure> (file:///tmp/tmpRpxoJi/dart-2.7.1/dart/pkg/compiler/lib/src/compiler.dart:210:20) #33 CompilerTask.measureSubtask (file:///tmp/tmpRpxoJi/dart-2.7.1/dart/pkg/compiler/lib/src/common/tasks.dart:179:35) #34 Compiler.run (file:///tmp/tmpRpxoJi/dart-2.7.1/dart/pkg/compiler/lib/src/compiler.dart:207:41) #35 CompilerImpl.run.<anonymous closure>.<anonymous closure> (file:///tmp/tmpRpxoJi/dart-2.7.1/dart/pkg/compiler/lib/src/apiimpl.dart:91:22) #36 _RootZone.runUnary (dart:async/zone.dart:1381:54) #37 _FutureListener.handleValue (dart:async/future_impl.dart:139:18) #38 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45) #39 Future._propagateToListeners (dart:async/future_impl.dart:709:32) #40 Future._completeWithValue (dart:async/future_impl.dart:524:5) #41 Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:554:7) #42 _microtaskLoop (dart:async/schedule_microtask.dart:43:21) #43 _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5) #44 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13) #45 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:175:5)
It looks like this has been fixed since that SDK release. When I try on 2.8.0-dev.8.0 I get the expected error:
2.8.0-dev.8.0
Error: Types parameters aren't allowed when defining an operator. Try removing the type parameters.
The following code crashes the compiler on all platforms, including dartpad: