1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 12:24:49 +01:00

Fix #4759 – don’t generate assertion when assigning to same-named variable

This commit is contained in:
Matt Brown 2020-12-03 09:42:20 -05:00 committed by Daniil Gentili
parent fcf2bc3831
commit 9c5cc02f90
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 12 additions and 0 deletions

View File

@ -1884,6 +1884,11 @@ class AssignmentAnalyzer
$codebase
);
$right_clauses = Context::filterClauses(
$var_id,
$right_clauses
);
$assignment_clauses = \Psalm\Internal\Algebra::combineOredClauses(
[new \Psalm\Internal\Clause([$var_id => ['falsy']], $var_object_id, $var_object_id)],
$right_clauses,

View File

@ -1052,6 +1052,13 @@ class TypeAlgebraTest extends \Psalm\Tests\TestCase
}
}'
],
'assignSameName' => [
'<?php
function foo(string $value): string {
$value = "yes" === $value;
return !$value ? "foo" : "bar";
}'
],
];
}