1
0
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:
Bruce Weirdan 2023-02-09 23:09:40 -04:00 committed by GitHub
commit 468cc215f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -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));

View File

@ -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',
],
],
];
}