compiler: use correct location for iota errors

Also check for valid array length when reducing len/cap to a constant.

For golang/go#8183

Change-Id: I09a896e252afc61fbfec92dceb447d3089838ee5
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/275654
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 files changed