[BUG] Return type and dtype of parameters in a function is incorrect
frankhart2018 opened this issue · 0 comments
frankhart2018 commented
Describe the bug
In the current implementation if a function is called with parameters of different types then the compiled C version of the function has the type from the final call, but the return type is set from the very first call. There can be two resolutions to this problem:-
- Throw an error when types change
- Name mangling (Follow this source if you don't know what name mangling means).
Steps to Reproduce
For this simC code:-
fun sum(a, b) {
return a + b
}
MAIN
var res = sum(1, 2)
var res1 = sum(3.14, 4.2)
END_MAIN
The following C code is generated:-
int sum(float a, float b) {
return a + b;
}
int main() {
int res = sum(1, 2);
int res1 = sum(3.14, 4.2);
return 0;
}
Note: I have started a discussion for this, if anyone wants to work in this then please express your views regarding both the choices in this discussion:- 484.