leonardt / hwtypes

Python implementations of fixed size hardware types (Bit, BitVector, UInt, SInt, ...) based on the SMT-LIB2 semantics
BSD 3-Clause "New" or "Revised" License
18 stars 4 forks source link

Too eager of casting in SMTBit.ite #107

Closed rdaly525 closed 4 years ago

rdaly525 commented 4 years ago

I would expect the following to raise a type error. Is this expected behavior or a bug?

p = SMTBit()
t = SMTBit()
f = SMTBitVector[1]()
#This does not raise a type error
res = p.ite(t,f)
cdonovick commented 4 years ago

This basically is question about whether the following should work: bit.ite(bv, 5) All of the other operators / methods currently will try to coerce there operands. The fact the operand is a bit should not matter to this rule.

cdonovick commented 4 years ago

I am fine with removing coercion from the ITE. I am not okay with special casing bit.

cdonovick commented 4 years ago

Actually I think I can block this specific behavior by first trying to cast to bit, before tying to cast to bv.