compiler: support any int type in slice indexes

Make sure the compiler will correctly compile indexes of type uint64,
for example.
This commit is contained in:
Ayke van Laethem
2018-11-14 14:41:40 +01:00
parent ee7c276493
commit 9bddaae04a
3 changed files with 104 additions and 22 deletions
+3 -3
View File
@@ -43,14 +43,14 @@ func lookupBoundsCheckLong(length uintptr, index int64) {
}
// Check for bounds in *ssa.Slice.
func sliceBoundsCheck(capacity uintptr, low, high uint) {
if !(0 <= low && low <= high && high <= uint(capacity)) {
func sliceBoundsCheck(capacity, low, high uintptr) {
if !(0 <= low && low <= high && high <= capacity) {
runtimePanic("slice out of range")
}
}
// Check for bounds in *ssa.Slice. Supports 64-bit indexes.
func sliceBoundsCheckLong(capacity uintptr, low, high uint64) {
func sliceBoundsCheck64(capacity uintptr, low, high uint64) {
if !(0 <= low && low <= high && high <= uint64(capacity)) {
runtimePanic("slice out of range")
}