Skip to content

Commit

Permalink
bugfix: prevent infinite-loop when resolving type-aliases
Browse files Browse the repository at this point in the history
The type-expander returns the same `intersection_type` in case something is not properly expandable. To avoid infinite-loop, we do explicitly verify that the expanded  alias is actually resolved

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
  • Loading branch information
boesing committed Aug 27, 2023
1 parent 77436b1 commit d9ebab6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Psalm/Internal/Type/TypeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -1629,9 +1629,7 @@ private static function resolveTypeAliases(Codebase $codebase, array $intersecti
continue;
}

$modified = true;

$normalized_intersection_types[] = TypeExpander::expandAtomic(
$expanded_intersection_type = TypeExpander::expandAtomic(
$codebase,
$intersection_type,
null,
Expand All @@ -1644,6 +1642,9 @@ private static function resolveTypeAliases(Codebase $codebase, array $intersecti
true,
true,
);

$modified = $expanded_intersection_type[0] !== $intersection_type;
$normalized_intersection_types[] = $expanded_intersection_type;
}

if ($modified === false) {
Expand Down

0 comments on commit d9ebab6

Please sign in to comment.