Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix faulty comparison with typed closure #7175

Merged
merged 1 commit into from Dec 16, 2021

Conversation

muglug
Copy link
Collaborator

@muglug muglug commented Dec 16, 2021

When an explicit Closure(Foo):Bar type is given this code results in a MixedArgumentTypeCoercion.

It should just be an InvalidArgument: https://psalm.dev/r/0880d5dfe8

Seen in the course of my ongoing deep audit (rewriting most of the logic in Rust, with changes for Hack).

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/0880d5dfe8
<?php

/** @param Closure(int): string $c */
function takesClosure(Closure $c): void {
	$c(5);
}

takesClosure(5);
Psalm output (using commit 84d6777):

INFO: MixedArgumentTypeCoercion - 8:14 - Argument 1 of takesClosure expects Closure(int):string, parent type 5 provided

@muglug muglug added the release:fix The PR will be included in 'Fixes' section of the release notes label Dec 16, 2021
@weirdan weirdan merged commit f4b48ab into master Dec 16, 2021
@weirdan weirdan deleted the muglug-fix-closure-comparison branch December 16, 2021 17:50
@weirdan
Copy link
Collaborator

weirdan commented Dec 16, 2021

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:fix The PR will be included in 'Fixes' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants