Vexu/arocc

Crash: assign imaginary float to unsigned

Closed this issue · 0 comments

Only happens with unsigned integer types

unsigned long foo = 2.0i;
panic: access of union field 'int' while field 'complex' is active
/Users/ehaas/source/arocc/src/aro/Value.zig:352:48: 0x109d5c1ee in toBigInt (arocc)
    return switch (comp.interner.get(val.ref()).int) {
                                               ^
/Users/ehaas/source/arocc/src/aro/Value.zig:876:36: 0x109d8b0ae in compare (arocc)
    const lhs_bigint = lhs.toBigInt(&lhs_bigint_space, comp);
                                   ^
/Users/ehaas/source/arocc/src/aro/Value.zig:146:57: 0x109d8a822 in floatToInt (arocc)
    } else if (dest_ty.isUnsignedInt(comp) and v.compare(.lt, zero, comp)) {
                                                        ^