From e6138185db7f0c3390109b3324fc7478f7e20f97 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Sun, 8 Sep 2024 22:00:13 +0700 Subject: [PATCH] cmd/compile/internal/typecheck: simplify checkmake/checkunsafesliceorstring types2 handles all constant-related bounds checks in user Go code now, so it's safe to remove the constants check from these functions. Change-Id: I4e3fb5d22f9bbc95878c7df2ee3b0eb1819f8dd7 Reviewed-on: https://go-review.googlesource.com/c/go/+/611677 Auto-Submit: Cuong Manh Le Reviewed-by: Tim King LUCI-TryBot-Result: Go LUCI Reviewed-by: Keith Randall Reviewed-by: Keith Randall --- .../compile/internal/typecheck/typecheck.go | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/src/cmd/compile/internal/typecheck/typecheck.go b/src/cmd/compile/internal/typecheck/typecheck.go index cb48bfd7e3..0ebc13cac3 100644 --- a/src/cmd/compile/internal/typecheck/typecheck.go +++ b/src/cmd/compile/internal/typecheck/typecheck.go @@ -1209,20 +1209,6 @@ func checkmake(t *types.Type, arg string, np *ir.Node) bool { return false } - // Do range checks for constants before DefaultLit - // to avoid redundant "constant NNN overflows int" errors. - if n.Op() == ir.OLITERAL { - v := toint(n.Val()) - if constant.Sign(v) < 0 { - base.Errorf("negative %s argument in make(%v)", arg, t) - return false - } - if ir.ConstOverflow(v, types.Types[types.TINT]) { - base.Errorf("%s argument too large in make(%v)", arg, t) - return false - } - } - // DefaultLit is necessary for non-constants too: n might be 1.1<