@@ -21464,7 +21464,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
21464
21464
}
21465
21465
const id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol);
21466
21466
const entry = enumRelation.get(id);
21467
- if (entry !== undefined && !(!(entry & RelationComparisonResult.Reported) && entry & RelationComparisonResult.Failed && errorReporter)) {
21467
+ if (entry !== undefined && !(entry & RelationComparisonResult.Failed && errorReporter)) {
21468
21468
return !!(entry & RelationComparisonResult.Succeeded);
21469
21469
}
21470
21470
const targetEnumType = getTypeOfSymbol(targetSymbol);
@@ -21474,11 +21474,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
21474
21474
if (!targetProperty || !(targetProperty.flags & SymbolFlags.EnumMember)) {
21475
21475
if (errorReporter) {
21476
21476
errorReporter(Diagnostics.Property_0_is_missing_in_type_1, symbolName(sourceProperty), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType));
21477
- enumRelation.set(id, RelationComparisonResult.Failed | RelationComparisonResult.Reported);
21478
- }
21479
- else {
21480
- enumRelation.set(id, RelationComparisonResult.Failed);
21481
21477
}
21478
+ enumRelation.set(id, RelationComparisonResult.Failed);
21482
21479
return false;
21483
21480
}
21484
21481
const sourceValue = getEnumMemberValue(getDeclarationOfKind(sourceProperty, SyntaxKind.EnumMember)!).value;
@@ -21489,15 +21486,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
21489
21486
21490
21487
// If we have 2 enums with *known* values that differ, they are incompatible.
21491
21488
if (sourceValue !== undefined && targetValue !== undefined) {
21492
- if (!errorReporter) {
21493
- enumRelation.set(id, RelationComparisonResult.Failed);
21494
- }
21495
- else {
21489
+ if (errorReporter) {
21496
21490
const escapedSource = sourceIsString ? `"${escapeString(sourceValue)}"` : sourceValue;
21497
21491
const escapedTarget = targetIsString ? `"${escapeString(targetValue)}"` : targetValue;
21498
21492
errorReporter(Diagnostics.Each_declaration_of_0_1_differs_in_its_value_where_2_was_expected_but_3_was_given, symbolName(targetSymbol), symbolName(targetProperty), escapedTarget, escapedSource);
21499
- enumRelation.set(id, RelationComparisonResult.Failed | RelationComparisonResult.Reported);
21500
21493
}
21494
+ enumRelation.set(id, RelationComparisonResult.Failed);
21501
21495
return false;
21502
21496
}
21503
21497
@@ -21508,16 +21502,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
21508
21502
// Either way, we can assume that it's numeric.
21509
21503
// If the other is a string, we have a mismatch in types.
21510
21504
if (sourceIsString || targetIsString) {
21511
- if (!errorReporter) {
21512
- enumRelation.set(id, RelationComparisonResult.Failed);
21513
- }
21514
- else {
21505
+ if (errorReporter) {
21515
21506
const knownStringValue = sourceValue ?? targetValue;
21516
21507
Debug.assert(typeof knownStringValue === "string");
21517
21508
const escapedValue = `"${escapeString(knownStringValue)}"`;
21518
21509
errorReporter(Diagnostics.One_value_of_0_1_is_the_string_2_and_the_other_is_assumed_to_be_an_unknown_numeric_value, symbolName(targetSymbol), symbolName(targetProperty), escapedValue);
21519
- enumRelation.set(id, RelationComparisonResult.Failed | RelationComparisonResult.Reported);
21520
21510
}
21511
+ enumRelation.set(id, RelationComparisonResult.Failed);
21521
21512
return false;
21522
21513
}
21523
21514
}
@@ -21716,7 +21707,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
21716
21707
if (overflow) {
21717
21708
// Record this relation as having failed such that we don't attempt the overflowing operation again.
21718
21709
const id = getRelationKey(source, target, /*intersectionState*/ IntersectionState.None, relation, /*ignoreConstraints*/ false);
21719
- relation.set(id, RelationComparisonResult.Reported | RelationComparisonResult.Failed );
21710
+ relation.set(id, RelationComparisonResult.Failed | (relationCount <= 0 ? RelationComparisonResult.ComplexityOverflow : RelationComparisonResult.StackDepthOverflow) );
21720
21711
tracing?.instant(tracing.Phase.CheckTypes, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth });
21721
21712
const message = relationCount <= 0 ?
21722
21713
Diagnostics.Excessive_complexity_comparing_types_0_and_1 :
@@ -22617,9 +22608,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
22617
22608
const id = getRelationKey(source, target, intersectionState, relation, /*ignoreConstraints*/ false);
22618
22609
const entry = relation.get(id);
22619
22610
if (entry !== undefined) {
22620
- if (reportErrors && entry & RelationComparisonResult.Failed && !(entry & RelationComparisonResult.Reported )) {
22621
- // We are elaborating errors and the cached result is an unreported failure. The result will be reported
22622
- // as a failure, and should be updated as a reported failure by the bottom of this function .
22611
+ if (reportErrors && entry & RelationComparisonResult.Failed && !(entry & RelationComparisonResult.Overflow )) {
22612
+ // We are elaborating errors and the cached result is a failure not due to a comparison overflow,
22613
+ // so we will do the comparison again to generate an error message .
22623
22614
}
22624
22615
else {
22625
22616
if (outofbandVarianceMarkerHandler) {
@@ -22632,6 +22623,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
22632
22623
instantiateType(source, reportUnreliableMapper);
22633
22624
}
22634
22625
}
22626
+ if (reportErrors && entry & RelationComparisonResult.Overflow) {
22627
+ const message = entry & RelationComparisonResult.ComplexityOverflow ?
22628
+ Diagnostics.Excessive_complexity_comparing_types_0_and_1 :
22629
+ Diagnostics.Excessive_stack_depth_comparing_types_0_and_1;
22630
+ reportError(message, typeToString(source), typeToString(target));
22631
+ overrideNextErrorInfo++;
22632
+ }
22635
22633
return entry & RelationComparisonResult.Succeeded ? Ternary.True : Ternary.False;
22636
22634
}
22637
22635
}
@@ -22735,7 +22733,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
22735
22733
else {
22736
22734
// A false result goes straight into global cache (when something is false under
22737
22735
// assumptions it will also be false without assumptions)
22738
- relation.set(id, (reportErrors ? RelationComparisonResult.Reported : 0) | RelationComparisonResult.Failed | propagatingVarianceFlags);
22736
+ relation.set(id, RelationComparisonResult.Failed | propagatingVarianceFlags);
22739
22737
relationCount--;
22740
22738
resetMaybeStack(/*markAllAsSucceeded*/ false);
22741
22739
}
0 commit comments