Minres / CoreDSL

Xtext project to parse CoreDSL files
Apache License 2.0
16 stars 3 forks source link

Relax assignment rules for constant RHS #75

Open jopperm opened 1 year ago

jopperm commented 1 year ago

@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 9 months ago

@eyck we should make a decision on this.

eyck commented 9 months ago

I don't see an issue with this so it should be implemented.