check.invalidOp(x.Pos(), "shifted operand %s (type %s) must be integer", x, typ)
return
}
- } else if old.val != nil {
+ // Even if we have an integer, if the value is a constant we
+ // still must check that it is representable as the specific
+ // int type requested (was issue #22969). Fall through here.
+ }
+ if old.val != nil {
// If x is a constant, it must be representable as a value of typ.
c := operand{old.mode, x, old.typ, old.val, 0}
check.convertUntyped(&c, typ)
var _ = string(1 << s)
var _ = string(1.0 /* ERROR "cannot convert" */ << s)
}
+
+func issue22969() {
+ var s uint
+ var a []byte
+ _ = a[0xffffffffffffffff /* ERROR "overflows int" */ <<s] // example from issue 22969
+ _ = make([]int, 0xffffffffffffffff /* ERROR "overflows int" */ << s)
+ _ = make([]int, 0, 0xffffffffffffffff /* ERROR "overflows int" */ << s)
+ var _ byte = 0x100 /* ERROR "overflows byte" */ << s
+ var _ int8 = 0xff /* ERROR "overflows int8" */ << s
+ var _ int16 = 0xffff /* ERROR "overflows int16" */ << s
+ var _ int32 = 0x80000000 /* ERROR "overflows int32" */ << s
+}
\ No newline at end of file