-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go/ssa: removes conversion of index value in Index and IndexAddr to int
Removes the forced conversion of the Index field in Index and IndexAddr to type int. ssa/interp now intprets indices as int64s instead of ints. Converts untyped indices for strings to ints before the lookup. Fixes golang/go#50949 Change-Id: Ib5d7f1ad28728d16c8e0a8411014d1209c62a3f2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/387996 Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Tim King <taking@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Trust: Tim King <taking@google.com>
- Loading branch information
1 parent
9d8009b
commit 8e193c2
Showing
9 changed files
with
131 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2022 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// Test interpretation on 32 bit widths. | ||
|
||
package main | ||
|
||
func main() { | ||
mapSize() | ||
} | ||
|
||
func mapSize() { | ||
// Tests for the size argument of make on a map type. | ||
const tooBigFor32 = 1<<33 - 1 | ||
wantPanic( | ||
func() { | ||
_ = make(map[int]int, int64(tooBigFor32)) | ||
}, | ||
"runtime error: ssa.MakeMap.Reserve value 8589934591 does not fit in int", | ||
) | ||
|
||
// TODO: Enable the following if sizeof(int) can be different for host and target. | ||
// _ = make(map[int]int, tooBigFor32) | ||
// | ||
// Second arg to make in `make(map[int]int, tooBigFor32)` is an untyped int and | ||
// is converted into an int explicitly in ssa. | ||
// This has a different value on 32 and 64 bit systems. | ||
} | ||
|
||
func wantPanic(fn func(), s string) { | ||
defer func() { | ||
err := recover() | ||
if err == nil { | ||
panic("expected panic") | ||
} | ||
if got := err.(error).Error(); got != s { | ||
panic("expected panic " + s + " got " + got) | ||
} | ||
}() | ||
fn() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters