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.2k stars 1.57k forks source link

[cfe] Crash on type alias cyclicity #45085

Open eernstg opened 3 years ago

eernstg commented 3 years ago

Consider the following program:

typedef F<X> = Function<Y extends G<X>>();
typedef G<X> = Function(F<X>);

void main() {}

This program causes the front end (of 98c83633a2b54dd1709ddc1ee2a559214678be2b as well as 2.13.0-48.0.dev) to crash as follows:

Crash when compiling null,
at character offset null:
Bad state: Can't compute nullability from an absent bound.
#0      TypeParameterType.computeNullabilityFromBound (package:kernel/ast.dart:9664:7)
#1      new TypeParameterType.forAlphaRenaming (package:kernel/ast.dart:9532:18)
#2      _InnerTypeSubstitutor.freshTypeParameter (package:kernel/type_algebra.dart:386:13)
#3      MappedListIterable.elementAt (dart:_internal/iterable.dart:412:31)
#4      ListIterator.moveNext (dart:_internal/iterable.dart:341:26)
#5      new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:188:27)
#6      new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#7      new List.of (dart:core-patch/array_patch.dart:50:28)
#8      ListIterable.toList (dart:_internal/iterable.dart:212:44)
#9      _TypeSubstitutor.freshTypeParameters (package:kernel/type_algebra.dart:523:47)
#10     _TypeSubstitutor.visitFunctionType (package:kernel/type_algebra.dart:553:15)
#11     FunctionType.accept (package:kernel/ast.dart:8998:42)
#12     _TypeSubstitutor.visit (package:kernel/type_algebra.dart:488:41)
...
johnniwinther commented 3 years ago

cc @stefantsov