daphne-eu / daphne

DAPHNE: An Open and Extensible System Infrastructure for Integrated Data Analysis Pipelines
Apache License 2.0
67 stars 62 forks source link

[DAPHNE-#680] bug fix for signed integer casts #744

Closed AlexRTer closed 4 months ago

AlexRTer commented 5 months ago

This PR aims to fix #680.

When converting to any signed integer type that was longer than the input type during CastOp folding, the operand was always sign extended. This resulted in an incorrect conversion for unsigned and signless operands with a set most significant bit. E.g.

print(as.si8(true));            // -1
print(as.si32(as.ui8(255)));    // -1

Operands that are casted to a signed integer type are now zero extended instead if the input was not a signed integer type as well. There is a small test to guarantee the correct conversion.

philipportner commented 4 months ago

Thanks for the fix @AlexRTer !