]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: fix typecheck range over negative integer
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Thu, 5 Oct 2023 04:11:51 +0000 (11:11 +0700)
committerGopher Robot <gobot@golang.org>
Mon, 9 Oct 2023 18:09:34 +0000 (18:09 +0000)
commit778880b00888066212864f95877c0febbebf7e69
treeb1e315e14f31cc4f8cbacacc3c4d35fb14b0d04d
parentede27fb4aca9ab103413aff71b254f10db2b302a
cmd/compile: fix typecheck range over negative integer

Before range over integer, types2 leaves constant expression in RHS of
non-constant shift untyped, so idealType do the validation to ensure
that constant value must be an int >= 0.

With range over int, the range expression can also be left untyped, and
can be an negative integer, causing the validation false.

Fixing this by relaxing the validation in idealType, and moving the
check to Unified IR reader.

Fixes #63378

Change-Id: I43042536c09afd98d52c5981adff5dbc5e7d882a
Reviewed-on: https://go-review.googlesource.com/c/go/+/532835
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/noder/helpers.go
src/cmd/compile/internal/noder/reader.go
test/range3.go