From 73db2f85aab25c06f47c832364600d2c5e243ffa Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Wed, 4 Mar 2026 17:05:30 +0700 Subject: [PATCH] cmd/compile: remove left over constant checking Updates #77919 Change-Id: I300025cbfc1baf95dacde0ef66bd4b13484f2aa4 Reviewed-on: https://go-review.googlesource.com/c/go/+/751380 Reviewed-by: Keith Randall Reviewed-by: Keith Randall Reviewed-by: Cherry Mui Auto-Submit: Cuong Manh Le LUCI-TryBot-Result: Go LUCI --- src/cmd/compile/internal/typecheck/expr.go | 5 ----- src/cmd/compile/internal/typecheck/func.go | 14 -------------- 2 files changed, 19 deletions(-) diff --git a/src/cmd/compile/internal/typecheck/expr.go b/src/cmd/compile/internal/typecheck/expr.go index 7dc29636cc..53c291291f 100644 --- a/src/cmd/compile/internal/typecheck/expr.go +++ b/src/cmd/compile/internal/typecheck/expr.go @@ -6,7 +6,6 @@ package typecheck import ( "fmt" - "go/constant" "internal/types/errors" "strings" @@ -846,10 +845,6 @@ func tcStringHeader(n *ir.StringHeaderExpr) ir.Node { n.Ptr = Expr(n.Ptr) n.Len = DefaultLit(Expr(n.Len), types.Types[types.TINT]) - if ir.IsConst(n.Len, constant.Int) && ir.Int64Val(n.Len) < 0 { - base.Fatalf("len for OSTRINGHEADER must be non-negative") - } - return n } diff --git a/src/cmd/compile/internal/typecheck/func.go b/src/cmd/compile/internal/typecheck/func.go index 5765731546..79093e5194 100644 --- a/src/cmd/compile/internal/typecheck/func.go +++ b/src/cmd/compile/internal/typecheck/func.go @@ -12,7 +12,6 @@ import ( "fmt" "go/constant" - "go/token" ) // MakeDotArgs package all the arguments that match a ... T parameter into a []T. @@ -564,11 +563,6 @@ func tcMake(n *ir.CallExpr) ir.Node { n.SetType(nil) return n } - if ir.IsConst(l, constant.Int) && r != nil && ir.IsConst(r, constant.Int) && constant.Compare(l.Val(), token.GTR, r.Val()) { - base.Errorf("len larger than cap in make(%v)", t) - n.SetType(nil) - return n - } nn = ir.NewMakeExpr(n.Pos(), ir.OMAKESLICE, l, r) case types.TMAP: @@ -655,14 +649,6 @@ func tcMakeSliceCopy(n *ir.MakeExpr) ir.Node { base.Errorf("non-integer len argument in OMAKESLICECOPY") } - if ir.IsConst(n.Len, constant.Int) { - if ir.ConstOverflow(n.Len.Val(), types.Types[types.TINT]) { - base.Fatalf("len for OMAKESLICECOPY too large") - } - if constant.Sign(n.Len.Val()) < 0 { - base.Fatalf("len for OMAKESLICECOPY must be non-negative") - } - } return n }