Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Return type and dtype of parameters in a function is incorrect #482

Open
frankhart2018 opened this issue Jan 26, 2021 · 0 comments
Open
Labels
bug Something isn't working moderate Moderate problem

Comments

@frankhart2018
Copy link
Member

frankhart2018 commented Jan 26, 2021

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:-

  1. Throw an error when types change
  2. 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.

@frankhart2018 frankhart2018 added bug Something isn't working moderate Moderate problem SWoC 2021 labels Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working moderate Moderate problem
Projects
None yet
Development

No branches or pull requests

1 participant