Closed
Description
When calling recursively a templated function, types seems to be wrong.
Steps to reproduce
Compile the following code:
function foo<T1,T2>(): string {
if(isInteger<T2>()){
return foo<T2, T1>();
}
return nameof<T1>();
}
export function test(): string {
return foo<f64, i32>();
}
Expected behavior
Function test()
should return "i32"
.
But this code generate an unexpected infinite loop because of recursive call with wrong types:
(func $module/foo<i32,i32> (result i32)
i32.const 1
drop
call $module/foo<i32,i32>
return
)
(func $module/foo<f64,i32> (result i32)
i32.const 1
drop
call $module/foo<i32,i32> ;; Should be `call $module/foo<i32,f64>`
return
)
(func $module/test (result i32)
call $module/foo<f64,i32>
)