Source file src/internal/types/testdata/fixedbugs/issue51376.go

     1  // Copyright 2022 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 p
     6  
     7  type Map map[string]int
     8  
     9  func f[M ~map[K]V, K comparable, V any](M) {}
    10  func g[M map[K]V, K comparable, V any](M) {}
    11  
    12  func _[M1 ~map[K]V, M2 map[K]V, K comparable, V any]() {
    13          var m1 M1
    14          f(m1)
    15          g /* ERROR "M1 does not satisfy map[K]V" */ (m1) // M1 has tilde
    16  
    17          var m2 M2
    18          f(m2)
    19          g(m2) // M1 does not have tilde
    20  
    21          var m3 Map
    22          f(m3)
    23          g /* ERROR "Map does not satisfy map[string]int" */ (m3) // M in g does not have tilde
    24  }
    25  

View as plain text