Relax assignment rules for constant RHS
jopperm opened this issue · 2 comments
jopperm commented
@AtomCrafty suggested in #29:
What about if we instead calculate all expressions in the same manner, but allow assignments where the assigned value is a constant that fits into the assignment target, even if the static type of the expression is larger?
This would be in line with the other casting rules: A narrowing cast, but with the guarantee that no precision is lost. Comes in handy in certain edge cases, e.g. the following probably should be valid but isn't right now:
signed<4> x = -8; // UnaryMinus(IntLiteral(8) : unsigned<4>) : signed<5>
AtomCrafty commented
@eyck we should make a decision on this.
eyck commented
I don't see an issue with this so it should be implemented.