Skip to content

Fix infinite recursion for template intersection type accepts()#1450

Merged
ondrejmirtes merged 1 commit intophpstan:1.7.xfrom
rvanvelzen:bug-7500
Jun 21, 2022
Merged

Fix infinite recursion for template intersection type accepts()#1450
ondrejmirtes merged 1 commit intophpstan:1.7.xfrom
rvanvelzen:bug-7500

Conversation

@rvanvelzen
Copy link
Copy Markdown
Contributor

Comment on lines -147 to -150
if ($acceptingType instanceof self || ($acceptingType instanceof UnionType && !$acceptingType instanceof TemplateUnionType)) {
return $acceptingType->accepts($this, $strictTypes);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing appears to break by removing this 🤷‍♂️

@ondrejmirtes ondrejmirtes merged commit e4a1b67 into phpstan:1.7.x Jun 21, 2022
@ondrejmirtes
Copy link
Copy Markdown
Member

Thank you! Removing code is always nice 😊

@rvanvelzen rvanvelzen deleted the bug-7500 branch June 21, 2022 07:51
@VincentLanglet
Copy link
Copy Markdown
Contributor

@rvanvelzen @ondrejmirtes Am I wrong or the testBug7500 shouldn't report any error ?

https://phpstan.org/r/29203f2e-5b6c-46bf-b91a-baf7d3839591 works fine
but https://phpstan.org/r/05a8098a-1a57-460c-8707-3027e65605da doesn't.

\PHPStan\dumpType($res[$position]);

is PositionEntityInterface&TgEntityInterface but since

/** @phpstan-var array<T> $res */
$res = [];

it should be T of PositionEntityInterface&TgEntityInterface IMHO.

Should I open an issue ?

@ondrejmirtes
Copy link
Copy Markdown
Member

@VincentLanglet Comments on closed PRs tend to get lost, please open a new bug report about this, thanks.

@VincentLanglet
Copy link
Copy Markdown
Contributor

Yes I did it @ondrejmirtes phpstan/phpstan#7511 with a simpler reproducer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Child process error (exit code 139): Segmentation fault (core dumped) since phpstan 1.17.15

3 participants