rigetti / quil-rs

Quil Parser & Program Builder
https://rigetti.github.io/quil-rs/
Apache License 2.0
20 stars 9 forks source link

proptest_assert_eq may consider NaN == NaN to be false #367

Closed erichulburd closed 4 months ago

erichulburd commented 6 months ago

See the results of this job in MSRV task: https://github.com/rigetti/quil-rs/actions/runs/8790199931/job/24121695036

Test failed: assertion failed: `(left == right)` 
  left: `Number(Complex { re: NaN, im: 0.0 })`, 
 right: `Number(Complex { re: NaN, im: 0.0 })`: Simplified expressions should be equal:
parenthesized aa[0]/sin(pi) ("aa[0]/sin(pi)") extracted from (aa[0]/(sin(pi))) simplified to NaN
vs original aa[0]/sin(pi) ("aa[0]/sin(pi)") simplified to NaN at quil-rs/src/expression/mod.rs:993.
minimal failing input: e = Infix(
    InfixExpression {
        left: Address(
            MemoryReference {
                name: "aa",
                index: 0,
            },
        ),
        operator: Slash,
        right: FunctionCall(
            FunctionCallExpression {
                function: Sine,
                expression: PiConstant,
            },
        ),
    },
)

I've added this test case locally to specific_round_trip_tests, but couldn't reproduce the failure. That being the case, I suppose we can wrap that particular test case to check for the NaN case.