diff options
Diffstat (limited to 'src/cmd/compile/internal/noder/reader.go')
| -rw-r--r-- | src/cmd/compile/internal/noder/reader.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/noder/reader.go b/src/cmd/compile/internal/noder/reader.go index 1c0d0a9acc..3cd7b7c683 100644 --- a/src/cmd/compile/internal/noder/reader.go +++ b/src/cmd/compile/internal/noder/reader.go @@ -2233,6 +2233,13 @@ func (r *reader) expr() (res ir.Node) { switch op { case ir.OANDAND, ir.OOROR: return typecheck.Expr(ir.NewLogicalExpr(pos, op, x, y)) + case ir.OLSH, ir.ORSH: + // Untyped rhs of non-constant shift, e.g. x << 1.0. + // If we have a constant value, it must be an int >= 0. + if ir.IsConstNode(y) { + val := constant.ToInt(y.Val()) + assert(val.Kind() == constant.Int && constant.Sign(val) >= 0) + } } return typecheck.Expr(ir.NewBinaryExpr(pos, op, x, y)) |
