x.typ = Typ[UntypedBool]
}
-func (check *Checker) shift(x, y *operand, op token.Token) {
+func (check *Checker) shift(x, y *operand, e *ast.BinaryExpr, op token.Token) {
untypedx := isUntyped(x.typ)
// The lhs must be of integer type or be representable
x.typ = Typ[UntypedInt]
}
x.val = constant.Shift(x.val, op, uint(s))
+ // Typed constants must be representable in
+ // their type after each constant operation.
+ if isTyped(x.typ) {
+ if e != nil {
+ x.expr = e // for better error message
+ }
+ check.representable(x, x.typ.Underlying().(*Basic))
+ }
return
}
}
if isShift(op) {
- check.shift(x, &y, op)
+ check.shift(x, &y, e, op)
return
}