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

Wrong type combination: list<positive-int> + int = list<positive-int> #7090

Closed
klimick opened this issue Dec 7, 2021 · 1 comment · Fixed by #7093
Closed

Wrong type combination: list<positive-int> + int = list<positive-int> #7090

klimick opened this issue Dec 7, 2021 · 1 comment · Fixed by #7093
Labels

Comments

@klimick
Copy link
Contributor

klimick commented Dec 7, 2021

https://psalm.dev/r/cc223d445f

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/cc223d445f
<?php

/**
 * @return int
 */
function int(): int
{
	return 0;
}

/**
 * @return list<positive-int>
 */
function posiviteIntegers(): array
{
	return [1];
}

// int + list<positive-int> = list<int>
$_correct = [int(), ...posiviteIntegers()];
/** @psalm-trace $_correct */;

// list<positive-int> + int = list<positive-int>
$_incorrect = [...posiviteIntegers(), int()];
/** @psalm-trace $_incorrect */;
Psalm output (using commit a1b5e48):

INFO: Trace - 21:30 - $_correct: non-empty-list<int>

INFO: Trace - 25:32 - $_incorrect: non-empty-list<positive-int>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants