-
- Downloads
cmd/compile: don't evaluate side effects of range over array
If the thing we're ranging over is an array or ptr to array, and it doesn't have a function call or channel receive in it, then we shouldn't evaluate it. Typecheck the ranged-over value as a constant in that case. That makes the unified exporter replace the range expression with a constant int. Change-Id: I0d4ea081de70d20cf6d1fa8d25ef6cb021975554 Reviewed-on: https://go-review.googlesource.com/c/go/+/659317 Reviewed-by:Junyang Shao <shaojunyang@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by:
Robert Griesemer <gri@google.com>
Showing
- src/cmd/compile/internal/ssa/nilcheck.go 2 additions, 2 deletionssrc/cmd/compile/internal/ssa/nilcheck.go
- src/cmd/compile/internal/types2/range.go 25 additions, 0 deletionssrc/cmd/compile/internal/types2/range.go
- src/cmd/compile/internal/walk/range.go 30 additions, 5 deletionssrc/cmd/compile/internal/walk/range.go
- src/go/types/range.go 25 additions, 0 deletionssrc/go/types/range.go
- test/codegen/issue52635.go 12 additions, 0 deletionstest/codegen/issue52635.go
Loading
Please register or sign in to comment