Skip to content
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

Dart 3 compiler crashes in Dartpad #52438

Closed
ragnor-rs opened this issue May 18, 2023 · 6 comments
Closed

Dart 3 compiler crashes in Dartpad #52438

ragnor-rs opened this issue May 18, 2023 · 6 comments
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. dart2js-crash web-dart2js

Comments

@ragnor-rs
Copy link

The following snippet crashes Dart 3 compiler in Dartpad:

void main() {
  final tuple = ('1', 2, ['zz', false]);
  Object x = tuple;
  switch(x) {
    case (String a, int b, String c, bool d):
      print('tuple1($a, $b, $c, $d)');
  }
}

Based on Flutter 3.11.0-5.0.pre Dart SDK 3.1.0-85.0.dev

@ragnor-rs
Copy link
Author

This value also crashes the compiler

final tuple = ('1', 2, ('zz', false));

(changing the list to a record)

Stacktrace:

Error compiling to JavaScript:
Info: Compiling with sound null safety.
file:///tmp/dartpadMJXCJL/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-85.0.dev), and

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

The compiler crashed: RangeError (index): Invalid value: Not in inclusive range 0..2: -1
#0      List.[] (dart:core-patch/growable_array.dart:264:36)
#1      CommonMasks.getGetterTypeInRecord (package:compiler/src/inferrer/typemasks/masks.dart:921:22)
#2      RecordFieldAccessTypeInformation.computeType (package:compiler/src/inferrer/type_graph_nodes.dart:2151:10)
#3      TypeInformation.refine (package:compiler/src/inferrer/type_graph_nodes.dart:227:54)
#4      InferrerEngine._refine (package:compiler/src/inferrer/engine.dart:778:36)
#5      DurationMetric.measure (package:compiler/src/common/metrics.dart:74:22)
#6      InferrerEngine._runOverAllElements (package:compiler/src/inferrer/engine.dart:348:21)
#7      DurationMetric.measure (package:compiler/src/common/metrics.dart:74:22)
#8      InferrerEngine.runOverAllElements (package:compiler/src/inferrer/engine.dart:336:18)
#9      TypeGraphInferrer.analyzeMain (package:compiler/src/inferrer/type_graph_inferrer.dart:45:14)
#10     GlobalTypeInferenceTask.runGlobalTypeInference.<anonymous closure> (package:compiler/src/inferrer/types.dart:196:28)
#11     CompilerTask.measure (package:compiler/src/common/tasks.dart:66:51)
#12     GlobalTypeInferenceTask.runGlobalTypeInference (package:compiler/src/inferrer/types.dart:187:12)
#13     Compiler.performGlobalTypeInference (package:compiler/src/compiler.dart:512:28)
#14     Compiler.produceGlobalTypeInferenceResults (package:compiler/src/compiler.dart:649:26)
#15     Compiler.runSequentialPhases (package:compiler/src/compiler.dart:737:15)
<asynchronous suspension>
#16     Compiler.runInternal.<anonymous closure> (package:compiler/src/compiler.dart:310:7)
<asynchronous suspension>
#17     Compiler.runInternal (package:compiler/src/compiler.dart:309:5)
<asynchronous suspension>
#18     Compiler.run.<anonymous closure> (package:compiler/src/compiler.dart:229:11)
<asynchronous suspension>
#19     main (package:compiler/src/dart2js.dart:1485:3)
<asynchronous suspension>

@ragnor-rs
Copy link
Author

The above mentioned problem arises when using JS compiler. MacOS version runs ok:

Flutter 3.10.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision d3d8effc68 (2 days ago) • 2023-05-16 17:59:05 -0700
Engine • revision b4fb11214d
Tools • Dart 3.0.1 • DevTools 2.23.1

@sigmundch sigmundch added web-dart2js area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. labels May 18, 2023
@fishythefish
Copy link
Member

/cc @biggs0125

@biggs0125
Copy link

Working on a fix for this.

@biggs0125
Copy link

The fix for this has been checked in here: https://dart-review.googlesource.com/c/sdk/+/304380

I'm working on a cherrypick to stable for this fix.

@rakudrama
Copy link
Member

Verified compiler no longer crashes on sample.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. dart2js-crash web-dart2js
Projects
None yet
Development

No branches or pull requests

5 participants