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
The native PHIR-JSON engine loses foreign-call (ffcall) return values that are negative or wider than 32 bits.
Cause (from source on the #1314 branch; same on dev)
In crates/pecos-phir-json/src/v0_1/operations.rs (~1311, ~1324, ~1384, ~1396), ffcall results are converted with u32::try_from(result[i]).unwrap_or(0) (and similar). A negative return value, or one above u32::MAX, silently becomes 0 before it is stored. Some whole-result paths use u64::try_from(...).unwrap_or(0), which turns negative returns into 0 as well.
The default Rust interpreter and the Python interpreter keep the two's-complement value, so the same program gives different results depending on the PHIR path.
Direction
Convert ffcall returns into the destination register's type with the PHIR spec's integer semantics (variables behave as i64, then wrap to the declared width), the same way = assignment does, with no unwrap_or(0). If a value cannot be represented, report an error naming the call, the value and the destination. Add tests with negative and >32-bit returns on the native engine and both interpreters.
Activity