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.04k stars 1.55k forks source link

Internal problem: Unhandled Scope in toValue. #31195

Open lukechurch opened 6 years ago

lukechurch commented 6 years ago

Crash in fasta @peter-ahe-google id: 2f4144096b61139e62826ec1121a2b6703c4fbad

org-dartlang-bulkcompile:///main.dart: Internal problem: Unhandled Scope in toValue.
#0      internalProblem (package:front_end/src/fasta/problems.dart:29:3)
#1      unhandled (package:front_end/src/fasta/problems.dart:41:10)
#2      BodyBuilder.toValue (package:front_end/src/fasta/kernel/body_builder.dart:238:14)
#3      BodyBuilder.endBinaryExpression (package:front_end/src/fasta/kernel/body_builder.dart:889:30)
#4      Parser.parsePrecedenceExpression (package:front_end/src/fasta/parser/parser.dart:3727:20)
#5      Parser.parseExpression (package:front_end/src/fasta/parser/parser.dart:3642:11)
#6      Parser.parseFieldInitializerOpt (package:front_end/src/fasta/parser/parser.dart:2616:15)
#7      Parser.parseFields (package:front_end/src/fasta/parser/parser.dart:2346:13)
#8      Parser.parseMember (package:front_end/src/fasta/parser/parser.dart:2980:11)
#9      DietListener.parseFields (package:front_end/src/fasta/source/diet_listener.dart:658:22)
#10     DietListener.buildFields (package:front_end/src/fasta/source/diet_listener.dart:522:5)
#11     DietListener.endFields (package:front_end/src/fasta/source/diet_listener.dart:218:5)
#12     Parser.parseFields (package:front_end/src/fasta/parser/parser.dart:2358:16)
#13     Parser.parseMember (package:front_end/src/fasta/parser/parser.dart:2980:11)
#14     Parser.parseClassBody (package:front_end/src/fasta/parser/parser.dart:2866:15)
#15     Parser.parseClass (package:front_end/src/fasta/parser/parser.dart:1223:13)
#16     Parser.parseClassOrNamedMixinApplication (package:front_end/src/fasta/parser/parser.dart:1183:14)
#17     Parser.parseTopLevelKeywordDeclaration (package:front_end/src/fasta/parser/parser.dart:361:14)
#18     Parser.parseTopLevelDeclarationImpl (package:front_end/src/fasta/parser/parser.dart:295:14)
#19     Parser.parseUnit (package:front_end/src/fasta/parser/parser.dart:271:15)
#20     SourceLoader.buildBody (package:front_end/src/fasta/source/source_loader.dart:178:14)
<asynchronous suspension>
#21     Loader.buildBodies (package:front_end/src/fasta/loader.dart:125:13)
<asynchronous suspension>
#22     KernelTarget.buildProgram (package:front_end/src/fasta/kernel/kernel_target.dart:289:20)
<asynchronous suspension>
#23     generateKernelInternal (package:front_end/src/kernel_generator_impl.dart:127:36)
<asynchronous suspension>
#24     BulkCompiler.compile.<anonymous closure> (file:///Users/lukechurch/GitRepos/dart-sdk/sdk/pkg/front_end/tool/_fasta/bulk_compile.dart:52:37)
<asynchronous suspension>
#25     CompilerContext.runInContext.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:89:33)
#26     _rootRun (dart:async/zone.dart:1124)
#27     _CustomZone.run (dart:async/zone.dart:1021)
#28     runZoned (dart:async/zone.dart:1499)
#29     CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:89:12)
#30     CompilerContext.runWithOptions (package:front_end/src/fasta/compiler_context.dart:96:41)
#31     BulkCompiler.compile (file:///Users/lukechurch/GitRepos/dart-sdk/sdk/pkg/front_end/tool/_fasta/bulk_compile.dart:49:28)
#32     runFailedPath (file:///Users/lukechurch/GitRepos/dart-sdk/sdk/pkg/front_end/tool/_fasta/fuzz_driver.dart:69:27)
<asynchronous suspension>
#33     testDirectory (file:///Users/lukechurch/GitRepos/dart-sdk/sdk/pkg/front_end/tool/_fasta/fuzz_driver.dart:42:9)
<asynchronous suspension>
#34     main (file:///Users/lukechurch/GitRepos/dart-sdk/sdk/pkg/front_end/tool/_fasta/fuzz_driver.dart:137:7)
#35     _startIsolate.<anonymous closure> (dart:isolate-patch/dart:isolate/isolate_patch.dart:275)
#36     _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:163)
askeksa-google commented 6 years ago

Small reproduction case:

class MissingSemicolon {
  static int a = 10;

  static const int b = MissingSemicolon.a+MissingSemicolon.a

  MissingSemicolon() {}
}

If the initializer is shortened to MissingSemicolon.a, a different exception occurs:

Unhandled exception:
type 'Scope' is not a subtype of type 'Identifier' of 'identifier' where
  Scope is from package:front_end/src/fasta/scope.dart
  Identifier is from package:front_end/src/fasta/kernel/body_builder.dart

#0      BodyBuilder.finishFields (package:front_end/src/fasta/kernel/body_builder.dart:436:31)
#1      DietListener.listenerFinishFields (package:front_end/src/fasta/source/diet_listener.dart:668:14)
#2      DietListener.parseFields (package:front_end/src/fasta/source/diet_listener.dart:713:5)
#3      DietListener.buildFields (package:front_end/src/fasta/source/diet_listener.dart:554:5)
#4      DietListener.endFields (package:front_end/src/fasta/source/diet_listener.dart:224:5)
#5      Parser.parseFields (package:front_end/src/fasta/parser/parser.dart:2578:16)
#6      Parser.parseClassMember (package:front_end/src/fasta/parser/parser.dart:3257:11)
#7      Parser.parseClassBody (package:front_end/src/fasta/parser/parser.dart:3126:15)
#8      Parser.parseClass (package:front_end/src/fasta/parser/parser.dart:1390:13)
#9      Parser.parseClassOrNamedMixinApplication (package:front_end/src/fasta/parser/parser.dart:1349:14)
#10     Parser.parseTopLevelKeywordDeclaration (package:front_end/src/fasta/parser/parser.dart:434:14)
#11     Parser.parseTopLevelDeclarationImpl (package:front_end/src/fasta/parser/parser.dart:365:14)
#12     Parser.parseUnit (package:front_end/src/fasta/parser/parser.dart:308:15)
#13     SourceLoader.buildBody (package:front_end/src/fasta/source/source_loader.dart:181:14)
askeksa-google commented 6 years ago

No longer crashes.