The following code
var s int
var _ = 1 << ((-1 << s) + 1)
is permitted by the type checker (types2), but runs into a lower-level compiler error (playground):
invalid operation: -1 << s + uint(1) (mismatched types int and uint)
The following code
var s int
var _ = 1 << ((-1 << s) + int(1))
is accepted (playground).
This is particularly odd because in the first example, one would expect the right-most one to be typed as int.
This should be addressed after #77117 is resolved. Requiring that the -1 must fit into an int would likely address this.
The following code
is permitted by the type checker (types2), but runs into a lower-level compiler error (playground):
The following code
is accepted (playground).
This is particularly odd because in the first example, one would expect the right-most one to be typed as int.
This should be addressed after #77117 is resolved. Requiring that the -1 must fit into an int would likely address this.