Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checker: fix generic fn with generic fn call returning generic map (fix
- Loading branch information
Showing
4 changed files
with
34 additions
and
5 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
28 changes: 28 additions & 0 deletions
28
vlib/v/tests/generics_with_generics_fn_return_generics_map_type_test.v
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,28 @@ | ||
fn generic1[K, V](a map[K]V) string { | ||
t := expect_map[K, V](a) | ||
dump(t) | ||
return '${t}' | ||
} | ||
|
||
fn generic2[K, V](a map[K]V) string { | ||
t := expect_map(a) | ||
dump(t) | ||
return '${t}' | ||
} | ||
|
||
fn expect_map[K, V](a map[K]V) map[K]V { | ||
return a | ||
} | ||
|
||
fn test_generics_with_generics_fn_return_map_type() { | ||
a := { | ||
'a': 1 | ||
} | ||
b := { | ||
1: 'a' | ||
} | ||
assert generic1(a) == "{'a': 1}" | ||
assert generic1(b) == "{1: 'a'}" | ||
assert generic2(a) == "{'a': 1}" | ||
assert generic2(b) == "{1: 'a'}" | ||
} |
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