diff --git a/vlib/v/tests/generics/generic_as_cast_on_map_test.v b/vlib/v/tests/generics/generic_as_cast_on_map_test.v new file mode 100644 index 00000000000000..15393be045f806 --- /dev/null +++ b/vlib/v/tests/generics/generic_as_cast_on_map_test.v @@ -0,0 +1,14 @@ +type Sumtype = string | int + +fn generic_fn[T](x Sumtype) bool { + y := [x].map(it as T) + mut arr := []T{} + arr << x as T + dump(arr) + return arr.contains(y[0]) +} + +fn test_main() { + assert generic_fn[string]('hello') + assert generic_fn[int](123) +}