mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix #4802 - don’t clone context when analysing coalesce
This commit is contained in:
parent
d406d5b112
commit
f5dd6e76f8
@ -68,7 +68,7 @@ class CoalesceAnalyzer
|
||||
|
||||
$statements_analyzer->node_data = clone $statements_analyzer->node_data;
|
||||
|
||||
ExpressionAnalyzer::analyze($statements_analyzer, $ternary, clone $context);
|
||||
ExpressionAnalyzer::analyze($statements_analyzer, $ternary, $context);
|
||||
|
||||
$ternary_type = $statements_analyzer->node_data->getType($ternary) ?: Type::getMixed();
|
||||
|
||||
|
@ -997,6 +997,15 @@ class IssetTest extends \Psalm\Tests\TestCase
|
||||
echo $arr["a"]["b"] ?? 0;
|
||||
}'
|
||||
],
|
||||
'coalescePreserveContext' => [
|
||||
'<?php
|
||||
function foo(array $test) : void {
|
||||
/** @psalm-suppress MixedArgument */
|
||||
echo $test[0] ?? ( $test[0] = 1 );
|
||||
/** @psalm-suppress MixedArgument */
|
||||
echo $test[0];
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user