-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
legacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.
Description
Original Issue: flutter/flutter#105840
I have a Flutter app which will not build on Web (release-mode). In all other platforms and in debug mode it builds fine. Further, the issue is not reproducible with dart2js.
The compiler crashed: Invalid argument(s): Type parameter TypeParameter(ConfigValue.T) is not indexed
#0 TypeParameterIndexer.[] (package:kernel/binary/ast_to_binary.dart:2921:8)
#1 BinaryPrinter.visitTypeParameterType (package:kernel/binary/ast_to_binary.dart:2426:38)
#2 TypeParameterType.accept (package:kernel/ast.dart:11890:42)
#3 BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
Crash Logs
$ flutter build web
💪 Building with sound null safety 💪
Target dart2js failed: Exception: Warning: The 'dart2js' entrypoint script is deprecated, please use 'dart compile js'
instead.
.dart_tool/flutter_build/d0b42d48aad4d4cb905f52ff662e43ea/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.17.1), and
* the entire message you see here (including the full stack trace
below as well as the source location above).
The compiler crashed: Invalid argument(s): Type parameter TypeParameter(ConfigValue.T) is not indexed
#0 TypeParameterIndexer.[] (package:kernel/binary/ast_to_binary.dart:2921:8)
#1 BinaryPrinter.visitTypeParameterType (package:kernel/binary/ast_to_binary.dart:2426:38)
#2 TypeParameterType.accept (package:kernel/ast.dart:11890:42)
#3 BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#4 BinaryPrinter.visitFunctionType (package:kernel/binary/ast_to_binary.dart:2397:7)
#5 FunctionType.accept (package:kernel/ast.dart:11218:42)
#6 BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#7 BinaryPrinter.writeOptionalNode (package:kernel/binary/ast_to_binary.dart:522:7)
#8 BinaryPrinter.visitConditionalExpression (package:kernel/binary/ast_to_binary.dart:1797:5)
#9 ConditionalExpression.accept (package:kernel/ast.dart:6679:44)
#10 BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#11 BinaryPrinter.visitInstanceCreation.<anonymous closure> (package:kernel/binary/ast_to_binary.dart:1841:7)
#12 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:614:13)
#13 BinaryPrinter.visitInstanceCreation (package:kernel/binary/ast_to_binary.dart:1839:22)
#14 InstanceCreation.accept (package:kernel/ast.dart:7076:44)
#15 BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#16 BinaryPrinter.visitFileUriExpression (package:kernel/binary/ast_to_binary.dart:1852:5)
#17 FileUriExpression.accept (package:kernel/ast.dart:7194:44)
#18 BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#19 BinaryPrinter.writeConstantTableEntry (package:kernel/binary/ast_to_binary.dart:289:7)
#20 BinaryPrinter.writeConstantTable (package:kernel/binary/ast_to_binary.dart:198:7)
#21 BinaryPrinter.writeComponentFile.<anonymous closure> (package:kernel/binary/ast_to_binary.dart:598:7)
#22 Timeline.timeSync (dart:developer/timeline.dart:157:22)
#23 BinaryPrinter.writeComponentFile (package:kernel/binary/ast_to_binary.dart:577:14)
#24 SerializationTask.serializeComponent.<anonymous closure> (package:compiler/src/serialization/task.dart:119:15)
#25 CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart:181:35)
#26 SerializationTask.serializeComponent (package:compiler/src/serialization/task.dart:110:5)
#27 Compiler.produceKernel (package:compiler/src/compiler.dart:411:33)
<asynchronous suspension>
#28 Compiler.runSequentialPhases (package:compiler/src/compiler.dart:621:33)
<asynchronous suspension>
#29 Compiler.runInternal.<anonymous closure> (package:compiler/src/compiler.dart:305:7)
<asynchronous suspension>
#30 Compiler.runInternal (package:compiler/src/compiler.dart:304:5)
<asynchronous suspension>
#31 main (package:compiler/src/dart2js.dart:1407:3)
<asynchronous suspension>
Compiling lib/main.dart for the Web... 2,616ms
Exception: Failed to compile application for the Web.
The issue is with a class which looks like the following. This is the smallest reproduction I could find.
Reproduction
T _identity<T extends Object>(String o) => o as T;
class ConfigValue<T extends Object> {
const ConfigValue._(
this.value, {
T Function(String)? parse,
}) : _parse = parse ?? _identity;
final String value;
final T Function(String) _parse;
}
void main() {
const myValue = ConfigValue<int>._(
String.fromEnvironment('MY_VALUE'),
parse: int.parse,
);
}
Building the above reproduction with dart2js works fine.
dart2js Logs
$ dart --version
Dart SDK version: 2.17.1 (stable) (Tue May 17 17:58:21 2022 +0000) on "macos_x64"
$ dart compile js -o main.dart.js main.dart
Info: Compiling with sound null safety
Compiled 9,540,220 characters Dart to 92,755 characters JavaScript in 0.72 seconds
Dart file main.dart compiled to JavaScript: main.dart.js
The issue appears on master
as well:
master Crash Logs
$ flutter build web
💪 Building with sound null safety 💪
Upgrading .gitignore
Compiling lib/main.dart for the Web...
Target dart2js failed: Exception: Warning: The 'dart2js' entrypoint script is deprecated, please use 'dart compile js' instead.
.dart_tool/flutter_build/cc613de6d9215dd6f5e75f306d00d5e3/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.18.0-178.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: Invalid argument(s): Type parameter TypeParameter(AWSConfigValue.T) is not indexed
#0 TypeParameterIndexer.[] (package:kernel/binary/ast_to_binary.dart:2947:8)
#1 BinaryPrinter.visitTypeParameterType (package:kernel/binary/ast_to_binary.dart:2452:38)
#2 TypeParameterType.accept (package:kernel/ast.dart:12216:42)
#3 BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#4 BinaryPrinter.visitFunctionType (package:kernel/binary/ast_to_binary.dart:2424:7)
#5 FunctionType.accept (package:kernel/ast.dart:11547:42)
#6 BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#7 BinaryPrinter.writeOptionalNode (package:kernel/binary/ast_to_binary.dart:522:7)
#8 BinaryPrinter.visitConditionalExpression (package:kernel/binary/ast_to_binary.dart:1823:5)
#9 ConditionalExpression.accept (package:kernel/ast.dart:6992:44)
#10 BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#11 BinaryPrinter.visitInstanceCreation.<anonymous closure> (package:kernel/binary/ast_to_binary.dart:1867:7)
#12 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:614:13)
#13 BinaryPrinter.visitInstanceCreation (package:kernel/binary/ast_to_binary.dart:1865:22)
#14 InstanceCreation.accept (package:kernel/ast.dart:7389:44)
#15 BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#16 BinaryPrinter.visitFileUriExpression (package:kernel/binary/ast_to_binary.dart:1878:5)
#17 FileUriExpression.accept (package:kernel/ast.dart:7507:44)
#18 BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:430:10)
#19 BinaryPrinter.writeConstantTableEntry (package:kernel/binary/ast_to_binary.dart:289:7)
#20 BinaryPrinter.writeConstantTable (package:kernel/binary/ast_to_binary.dart:198:7)
#21 BinaryPrinter.writeComponentFile.<anonymous closure> (package:kernel/binary/ast_to_binary.dart:598:7)
#22 Timeline.timeSync (dart:developer/timeline.dart:160:22)
#23 BinaryPrinter.writeComponentFile (package:kernel/binary/ast_to_binary.dart:577:14)
#24 SerializationTask.serializeComponent.<anonymous closure> (package:compiler/src/serialization/task.dart:124:15)
#25 CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart:181:35)
#26 SerializationTask.serializeComponent (package:compiler/src/serialization/task.dart:115:5)
#27 Compiler.produceKernel (package:compiler/src/compiler.dart:420:35)
<asynchronous suspension>
#28 Compiler.runSequentialPhases (package:compiler/src/compiler.dart:643:33)
<asynchronous suspension>
#29 Compiler.runInternal.<anonymous closure> (package:compiler/src/compiler.dart:309:7)
<asynchronous suspension>
#30 Compiler.runInternal (package:compiler/src/compiler.dart:308:5)
<asynchronous suspension>
#31 main (package:compiler/src/dart2js.dart:1424:3)
<asynchronous suspension>
Compiling lib/main.dart for the Web... 21.7s
Exception: Failed to compile application for the Web.
Metadata
Metadata
Assignees
Labels
legacy-area-front-endLegacy: Use area-dart-model instead.Legacy: Use area-dart-model instead.