From bf1b0973db38346afae460e80d18020fa7de4e8c Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Tue, 3 Mar 2026 23:10:05 +0700 Subject: cmd/compile/internal/typecheck: simplify tcSliceHeader types2 handles all constant-related bounds checks in user Go code now, so it's safe to remove all constants checking in tcSliceHeader function. Fixed #77919 Change-Id: Ibc137c84792d4898eb073cdeabac175684f73746 Reviewed-on: https://go-review.googlesource.com/c/go/+/751040 Reviewed-by: Keith Randall LUCI-TryBot-Result: Go LUCI Reviewed-by: Cherry Mui Reviewed-by: Keith Randall Auto-Submit: Cuong Manh Le --- src/cmd/compile/internal/typecheck/expr.go | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'src') diff --git a/src/cmd/compile/internal/typecheck/expr.go b/src/cmd/compile/internal/typecheck/expr.go index 44a69f0332..7dc29636cc 100644 --- a/src/cmd/compile/internal/typecheck/expr.go +++ b/src/cmd/compile/internal/typecheck/expr.go @@ -7,7 +7,6 @@ package typecheck import ( "fmt" "go/constant" - "go/token" "internal/types/errors" "strings" @@ -826,18 +825,6 @@ func tcSliceHeader(n *ir.SliceHeaderExpr) ir.Node { n.Len = DefaultLit(Expr(n.Len), types.Types[types.TINT]) n.Cap = DefaultLit(Expr(n.Cap), types.Types[types.TINT]) - if ir.IsConst(n.Len, constant.Int) && ir.Int64Val(n.Len) < 0 { - base.Fatalf("len for OSLICEHEADER must be non-negative") - } - - if ir.IsConst(n.Cap, constant.Int) && ir.Int64Val(n.Cap) < 0 { - base.Fatalf("cap for OSLICEHEADER must be non-negative") - } - - if ir.IsConst(n.Len, constant.Int) && ir.IsConst(n.Cap, constant.Int) && constant.Compare(n.Len.Val(), token.GTR, n.Cap.Val()) { - base.Fatalf("len larger than cap for OSLICEHEADER") - } - return n } -- cgit v1.3-5-g9baa