diff options
Diffstat (limited to 'src/cmd/compile/internal/typecheck/expr.go')
-rw-r--r-- | src/cmd/compile/internal/typecheck/expr.go | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/cmd/compile/internal/typecheck/expr.go b/src/cmd/compile/internal/typecheck/expr.go index 00615c506c..6bbb68550e 100644 --- a/src/cmd/compile/internal/typecheck/expr.go +++ b/src/cmd/compile/internal/typecheck/expr.go @@ -831,17 +831,11 @@ func tcSPtr(n *ir.UnaryExpr) ir.Node { // tcSlice typechecks an OSLICE or OSLICE3 node. func tcSlice(n *ir.SliceExpr) ir.Node { - n.X = Expr(n.X) - low, high, max := n.SliceBounds() + n.X = DefaultLit(Expr(n.X), nil) + n.Low = indexlit(Expr(n.Low)) + n.High = indexlit(Expr(n.High)) + n.Max = indexlit(Expr(n.Max)) hasmax := n.Op().IsSlice3() - low = Expr(low) - high = Expr(high) - max = Expr(max) - n.X = DefaultLit(n.X, nil) - low = indexlit(low) - high = indexlit(high) - max = indexlit(max) - n.SetSliceBounds(low, high, max) l := n.X if l.Type() == nil { n.SetType(nil) @@ -886,19 +880,19 @@ func tcSlice(n *ir.SliceExpr) ir.Node { return n } - if low != nil && !checksliceindex(l, low, tp) { + if n.Low != nil && !checksliceindex(l, n.Low, tp) { n.SetType(nil) return n } - if high != nil && !checksliceindex(l, high, tp) { + if n.High != nil && !checksliceindex(l, n.High, tp) { n.SetType(nil) return n } - if max != nil && !checksliceindex(l, max, tp) { + if n.Max != nil && !checksliceindex(l, n.Max, tp) { n.SetType(nil) return n } - if !checksliceconst(low, high) || !checksliceconst(low, max) || !checksliceconst(high, max) { + if !checksliceconst(n.Low, n.High) || !checksliceconst(n.Low, n.Max) || !checksliceconst(n.High, n.Max) { n.SetType(nil) return n } |