dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.22k stars 1.57k forks source link

Exception in the compiler compiling a Set literal #35989

Closed kika closed 5 years ago

kika commented 5 years ago

dart --version Dart VM version: 2.1.2-dev.0.0.flutter-0a7dcf17eb (Tue Feb 12 01:59:15 2019 +0000) on "macos_x64"

Code:

enum Skill {
 Math, English, Physics
}

class Teacher {
  final Set<Skill> skills;
  Teacher({Set<Skill> skills}) :  this.skills = skills ?? <Skill>{};
}

Result:

Crash when compiling file:///Users/kika/repro.dart,
at character offset 153:
NoSuchMethodError: The method 'accept' was called on null.
Receiver: null
Tried calling: accept(Instance of 'SetLiteralTransformer')
#0      Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
#1      BodyBuilder.finishFunction (package:front_end/src/fasta/kernel/body_builder.dart:754:12)
#2      DietListener.listenerFinishFunction (package:front_end/src/fasta/source/diet_listener.dart:803:14)
#3      DietListener.buildFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:837:7)
#4      DietListener.endMethod (package:front_end/src/fasta/source/diet_listener.dart:587:5)
#5      Parser.parseMethod (package:front_end/src/fasta/parser/parser.dart:3066:14)
#6      Parser.parseClassOrMixinMemberImpl (package:front_end/src/fasta/parser/parser.dart:2932:15)
#7      Parser.parseClassOrMixinBody (package:front_end/src/fasta/parser/parser.dart:2737:15)
#8      Parser.parseClass (package:front_end/src/fasta/parser/parser.dart:1761:13)
#9      Parser.parseClassOrNamedMixinApplication (package:front_end/src/fasta/parser/parser.dart:1721:14)
#10     Parser.parseTopLevelKeywordDeclaration (package:front_end/src/fasta/parser/parser.dart:573:14)
#11     Parser.parseTopLevelDeclarationImpl (package:front_end/src/fasta/parser/parser.dart:465:14)
#12     Parser.parseUnit (package:front_end/src/fasta/parser/parser.dart:348:15)
#13     SourceLoader.buildBody (package:front_end/src/fasta/source/source_loader.dart:257:14)
<asynchronous suspension>
#14     Loader.buildBodies (package:front_end/src/fasta/loader.dart:182:15)
<asynchronous suspension>
#15     KernelTarget.buildComponent.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:290:20)
<asynchronous suspension>
#16     withCrashReporting (package:front_end/src/fasta/crash.dart:122:24)
<asynchronous suspension>
#17     KernelTarget.buildComponent (package:front_end/src/fasta/kernel/kernel_target.dart:288:12)
<asynchronous suspension>
#18     generateKernelInternal.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:145:38)
<asynchronous suspension>
#19     withCrashReporting (package:front_end/src/fasta/crash.dart:122:24)
<asynchronous suspension>
#20     generateKernelInternal (package:front_end/src/kernel_generator_impl.dart:55:10)
<asynchronous suspension>
#21     generateKernel.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:40:18)
<asynchronous suspension>
#22     CompilerContext.runWithOptions.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:134:20)
<asynchronous suspension>
#23     CompilerContext.runInContext.<anonymous closure>.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:122:46)
#24     new Future.sync (dart:async/future.dart:224:31)
#25     CompilerContext.runInContext.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:122:19)
#26     _rootRun (dart:async/zone.dart:1124:13)
#27     _CustomZone.run (dart:async/zone.dart:1021:19)
#28     _runZoned (dart:async/zone.dart:1516:10)
#29     runZoned (dart:async/zone.dart:1463:12)
#30     CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:121:12)
#31     CompilerContext.runWithOptions (package:front_end/src/fasta/compiler_context.dart:132:10)
#32     generateKernel (package:front_end/src/kernel_generator_impl.dart:39:32)
<asynchronous suspension>
#33     kernelForComponent (package:front_end/src/api_prototype/kernel_generator.dart:83:17)
<asynchronous suspension>
#34     SingleShotCompilerWrapper.compileInternal (file:///b/rr/tmpgY2JrN/w/src/third_party/dart/pkg/vm/bin/kernel_service.dart:266:11)
<asynchronous suspension>
#35     Compiler.compile.<anonymous closure> (file:///b/rr/tmpgY2JrN/w/src/third_party/dart/pkg/vm/bin/kernel_service.dart:143:31)
<asynchronous suspension>
#36     new Future.<anonymous closure> (dart:async/future.dart:176:37)
#37     _rootRun (dart:async/zone.dart:1120:38)
#38     _CustomZone.run (dart:async/zone.dart:1021:19)
#39     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#40     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#41     _rootRun (dart:async/zone.dart:1124:13)
#42     _CustomZone.run (dart:async/zone.dart:1021:19)
#43     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:947:23)
#44     Timer._createTimer.<anonymous closure> (dart:async/runtime/libtimer_patch.dart:21:15)
#45     _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
#46     _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
#47     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)

#0      DietListener.buildFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:842:7)
#1      DietListener.endMethod (package:front_end/src/fasta/source/diet_listener.dart:587:5)
#2      Parser.parseMethod (package:front_end/src/fasta/parser/parser.dart:3066:14)
" Press ? for help             |enum Skill {
#3      Parser.parseClassOrMixinMemberImpl (package:front_end/src/fasta/parser/parser.dart:2932:15)
#4      Parser.parseClassOrMixinBody (package:front_end/src/fasta/parser/parser.dart:2737:15)
#5      Parser.parseClass (package:front_end/src/fasta/parser/parser.dart:1761:13)
#6      Parser.parseClassOrNamedMixinApplication (package:front_end/src/fasta/parser/parser.dart:1721:14)
#7      Parser.parseTopLevelKeywordDeclaration (package:front_end/src/fasta/parser/parser.dart:573:14)
#8      Parser.parseTopLevelDeclarationImpl (package:front_end/src/fasta/parser/parser.dart:465:14)
#9      Parser.parseUnit (package:front_end/src/fasta/parser/parser.dart:348:15)
#10     SourceLoader.buildBody (package:front_end/src/fasta/source/source_loader.dart:257:14)
<asynchronous suspension>
#11     Loader.buildBodies (package:front_end/src/fasta/loader.dart:182:15)
<asynchronous suspension>
#12     KernelTarget.buildComponent.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:290:20)
<asynchronous suspension>
#13     withCrashReporting (package:front_end/src/fasta/crash.dart:122:24)
<asynchronous suspension>
#14     KernelTarget.buildComponent (package:front_end/src/fasta/kernel/kernel_target.dart:288:12)
<asynchronous suspension>
#15     generateKernelInternal.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:145:38)
<asynchronous suspension>
#16     withCrashReporting (package:front_end/src/fasta/crash.dart:122:24)
<asynchronous suspension>
#17     generateKernelInternal (package:front_end/src/kernel_generator_impl.dart:55:10)
<asynchronous suspension>
#18     generateKernel.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:40:18)
<asynchronous suspension>
#19     CompilerContext.runWithOptions.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:134:20)
<asynchronous suspension>
#20     CompilerContext.runInContext.<anonymous closure>.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:122:46)
#21     new Future.sync (dart:async/future.dart:224:31)
#22     CompilerContext.runInContext.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:122:19)
#23     _rootRun (dart:async/zone.dart:1124:13)
#24     _CustomZone.run (dart:async/zone.dart:1021:19)
#25     _runZoned (dart:async/zone.dart:1516:10)
#26     runZoned (dart:async/zone.dart:1463:12)
#27     CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:121:12)
#28     CompilerContext.runWithOptions (package:front_end/src/fasta/compiler_context.dart:132:10)
#29     generateKernel (package:front_end/src/kernel_generator_impl.dart:39:32)
<asynchronous suspension>
#30     kernelForComponent (package:front_end/src/api_prototype/kernel_generator.dart:83:17)
<asynchronous suspension>
#31     SingleShotCompilerWrapper.compileInternal (file:///b/rr/tmpgY2JrN/w/src/third_party/dart/pkg/vm/bin/kernel_service.dart:266:11)
<asynchronous suspension>
#32     Compiler.compile.<anonymous closure> (file:///b/rr/tmpgY2JrN/w/src/third_party/dart/pkg/vm/bin/kernel_service.dart:143:31)
<asynchronous suspension>
#33     new Future.<anonymous closure> (dart:async/future.dart:176:37)
#34     _rootRun (dart:async/zone.dart:1120:38)
#35     _CustomZone.run (dart:async/zone.dart:1021:19)
#36     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#37     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#38     _rootRun (dart:async/zone.dart:1124:13)
#39     _CustomZone.run (dart:async/zone.dart:1021:19)
#40     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:947:23)
#41     Timer._createTimer.<anonymous closure> (dart:async/runtime/libtimer_patch.dart:21:15)
#42     _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
#43     _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
#44     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)

More succinct version Teacher({this.skills = const <Skill>{}}); gives the same result.

kmillikin commented 5 years ago

I made this a P1 because it's a crasher. @askeksa-google can you take a look?