You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary:
Bitwise operations (`&`, `|` and `^`) are currently typed incorrectly in two ways:
(1) When applied to arguments both of type `~int`, we produce `int`. This is wrong, because HHVM still accepts strings, so the `~` might hide a string type.
(2) In the dynamic pass, we produce `dynamic` regardless of the argument types, because of a call to `Typing_utils.is_dynamic` that is interpreted as dynamic-aware subtyping in the dynamic pass.
Instead, we now use a different approach of reusing the logic from SDT function calls, as though the bitwise op is a call to
<<__SupportDynamicType>> function bitwise(int $x, int $y):int
If interpreted strictly, this would produce `~int` if *either* of the operands is `~int` or `dynamic`. We can do slightly better, as we know that the operation will throw if one operand is `int` but the other is `string`. So a like is added only if *both* operands are `~int` or `dynamic`.
Reviewed By: mheiber
Differential Revision: D83841630
fbshipit-source-id: 57a12acbcf82d25eba632ee4ee50798b0071afa8
0 commit comments