mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: add sliceBound
Add a constant for the magic -1 for slice bounds. Use it. Enforce more aggressively that bounds must be slice, ddd, or non-negative. Remove ad hoc check in plive.go. Check bounds before constructing an array type when typechecking. All changes are manual. Passes toolstash -cmp. Change-Id: I9fd9cc789d7d4b4eea3b30b24037a254d3788add Reviewed-on: https://go-review.googlesource.com/21348 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
4b95575bd4
commit
e775b8df7a
5 changed files with 26 additions and 16 deletions
|
|
@ -277,7 +277,7 @@ func (p *importer) typ() *Type {
|
|||
|
||||
case arrayTag, sliceTag:
|
||||
t = p.newtyp(TARRAY)
|
||||
t.Bound = -1
|
||||
t.Bound = sliceBound
|
||||
if i == arrayTag {
|
||||
t.Bound = p.int64()
|
||||
}
|
||||
|
|
@ -285,7 +285,7 @@ func (p *importer) typ() *Type {
|
|||
|
||||
case dddTag:
|
||||
t = p.newtyp(TDDDFIELD)
|
||||
t.Bound = -1
|
||||
t.Bound = sliceBound
|
||||
t.Type = p.typ()
|
||||
|
||||
case structTag:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue