checker: prevent double module name prepending on generics types regi… (#9791)

pull/9799/head
Henrixounez 2021-04-18 15:26:40 +02:00 committed by GitHub
parent cfcecf898b
commit ee7bcfd05c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -1929,7 +1929,7 @@ pub fn (mut c Checker) fn_call(mut call_expr ast.CallExpr) ast.Type {
}
}
if has_generic_generic {
if c.mod != '' {
if c.mod != '' && !fn_name.starts_with('${c.mod}.') {
// Need to prepend the module when adding a generic type to a function
c.table.register_fn_generic_types(c.mod + '.' + fn_name, generic_types)
} else {

View File

@ -0,0 +1,12 @@
fn gen_fn2<T>(e T) string {
return '$e.str()'
}
fn gen_fn<T>(e T) string {
return gen_fn2<T>(e)
}
fn test_generics_in_generics() {
assert gen_fn(u64(42)) == '42'
assert gen_fn('42') == '42'
}