mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Merge pull request #9260 from weirdan/fix-crash-with-int-range-overflow
Fixes https://github.com/vimeo/psalm/issues/9114
This commit is contained in:
commit
468cc215f5
@ -80,6 +80,7 @@ use function assert;
|
||||
use function count;
|
||||
use function explode;
|
||||
use function get_class;
|
||||
use function is_int;
|
||||
use function min;
|
||||
use function strlen;
|
||||
use function strpos;
|
||||
@ -2000,7 +2001,7 @@ class SimpleAssertionReconciler extends Reconciler
|
||||
$existing_var_type->addType(new TIntRange($assertion_value, $atomic_type->value));
|
||||
}
|
||||
}*/
|
||||
} elseif ($atomic_type instanceof TInt) {
|
||||
} elseif ($atomic_type instanceof TInt && is_int($assertion_value)) {
|
||||
$redundant = false;
|
||||
$existing_var_type->removeType($atomic_type->getKey());
|
||||
$existing_var_type->addType(new TIntRange($assertion_value, null));
|
||||
|
@ -1017,6 +1017,19 @@ class IntRangeTest extends TestCase
|
||||
}
|
||||
',
|
||||
],
|
||||
'rangeOverflow' => [
|
||||
'code' => '<?php
|
||||
$i = (int)ceil(1);
|
||||
if ($i <= 9223372036854775807) {
|
||||
$z = $i;
|
||||
} else {
|
||||
$z = null;
|
||||
}
|
||||
',
|
||||
'assertions' => [
|
||||
'$z' => 'int<min, 9223372036854775807>|null',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user