Source file src/cmd/compile/internal/test/testdata/noalgtypelink/main.go
1 // Copyright 2026 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import ( 8 "internal/abi" 9 "reflect" 10 ) 11 12 type M map[int]int 13 14 var sink M 15 16 // M is used, not merely declared, so that the group type is built early 17 // enough for its noalg descriptor to be written first. 18 func useMap() { sink = M{1: 2} } 19 20 func main() { 21 useMap() 22 x := reflect.Zero(reflect.ArrayOf(abi.MapGroupSlots, reflect.TypeFor[int]())).Interface() 23 if _, ok := x.([abi.MapGroupSlots]int); !ok { 24 panic("array type from reflect.ArrayOf does not match the compiled one") 25 } 26 } 27