aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata/slice.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2020-05-27 00:17:28 +0200
committerRon Evans <[email protected]>2020-05-27 16:14:41 +0200
commitc248418dbec8c31d81fd8f8fedcdbd1fb93a85f1 (patch)
treeb8fce64dca0185b9fe48334e2479498aaee9f271 /testdata/slice.go
parent4ca2d3f0cf7b7e7b08770bd94be6edc98b7d48dd (diff)
downloadtinygo-c248418dbec8c31d81fd8f8fedcdbd1fb93a85f1.tar.gz
tinygo-c248418dbec8c31d81fd8f8fedcdbd1fb93a85f1.zip
compiler: fix a few crashes due to named types
There were a few cases left where a named type would cause a crash in the compiler. While going through enough code would have found them eventually, I specifically looked for the `Type().(` pattern: a Type() call that is then used in a type assert. Most of those were indeed bugs, although for some I couldn't come up with a reproducer so I left them as-is.
Diffstat (limited to 'testdata/slice.go')
-rw-r--r--testdata/slice.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/testdata/slice.go b/testdata/slice.go
index d20de76d3..b5e543671 100644
--- a/testdata/slice.go
+++ b/testdata/slice.go
@@ -31,6 +31,7 @@ func main() {
assert(len(make([]int, makeUint32(2), makeUint32(3))) == 2)
assert(len(make([]int, makeUint64(2), makeUint64(3))) == 2)
assert(len(make([]int, makeUintptr(2), makeUintptr(3))) == 2)
+ assert(len(make([]int, makeMyUint8(2), makeMyUint8(3))) == 2)
// indexing into a slice with uncommon index types
assert(foo[int(2)] == 4)
@@ -131,6 +132,9 @@ func main() {
var named MySlice
assert(len(unnamed[:]) == 32)
assert(len(named[:]) == 32)
+ for _, c := range named {
+ assert(c == 0)
+ }
}
func printslice(name string, s []int) {
@@ -169,3 +173,4 @@ func makeUint16(x uint16) uint16 { return x }
func makeUint32(x uint32) uint32 { return x }
func makeUint64(x uint64) uint64 { return x }
func makeUintptr(x uintptr) uintptr { return x }
+func makeMyUint8(x myUint8) myUint8 { return x }