Repository navigation
fix(types): account for overflow in negated float checks - #15495
Golden007-prog wants to merge 1 commit into
Conversation
|
bugbot review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 96d4a8e. Configure here.
✅ Performance: unchanged · Types: unchanged
How to read this table
head 96d4a8e · base be91d66 (merge-base) · workflow run |
psalm-bot
left a comment
There was a problem hiding this comment.
| Status | ✅ Ready: approved, merging is up to a maintainer |
|---|---|
| Approach | ✅ Root cause: negated float reconciliation ignored from_calculation |
| Correctness | ✅ No problems found: Only affects non-equality float negation on overflow-flagged int unions. |
| Tests | ✅ Prove the change: Valid case fails on base; two focused guards cover narrowing and bounded ranges. |
| Docs & comments | ✅ OK: One-line comment states why the check isn't redundant. |
SimpleNegatedAssertionReconciler::reconcileFloat() treated a non-equality !is_float() on an int union as redundant even when the union was flagged from_calculation. Integer arithmetic can overflow to float, so that check is not redundant. The PR starts $redundant as false for a non-equality assertion on a from_calculation union that contains an int. This matches the positive path (SimpleAssertionReconciler.php:561-566) and the int sibling (reconcileInt()). The narrowed type comes from combineRemainingTypes(), which drops from_calculation, so the true branch keeps int<2, max> without the overflow flag. The fix is in the reconciler that owns the negated float assertion, which is the right layer.
Automated review generated by AI; posted by psalm-bot.
Psalm reports a false
RedundantConditionfor!is_float()on an integer addition that may overflow to float.Before
After
Fixes #15490.