sim-c icon indicating copy to clipboard operation
sim-c copied to clipboard

[BUG] Function redefinition does not throw error

Open frankhart2018 opened this issue 3 years ago • 3 comments

Describe the bug When a function is redefined, then instead of throwing error, it compiles successfully. But the type of parameters of first remains not_known, while the redefinition gets the dtype for params.

Steps to Reproduce Consider the following simC code:-

fun sum(a, b) {
	return a + b;
}

fun sum(c, d) {
	return c - d;
}

MAIN
	var res = sum(1, 2)
	var res1 = sum(2, 1)
END_MAIN

This is the C code generated:-

int sum(not_known a, not_known b) {

	return a + b;
}

int sum(int c, int d) {

	return c - d;
}

int main() {
	int res = sum(1, 2);
	int res1 = sum(2, 1);

	return 0;
}

Expected behavior

It should throw an error:-

[Line 5] Error: Function sum redefined

frankhart2018 avatar Jan 26 '21 14:01 frankhart2018

Could this issue be assigned to me?

diivi avatar Oct 01 '21 07:10 diivi

Sure @diivi. Assigning this to you.

frankhart2018 avatar Oct 01 '21 07:10 frankhart2018

can you guide me as to where the code related to storing all functions/ something related to this issue is written? could not find a solution in the readme docs @frankhart2018

diivi avatar Oct 01 '21 20:10 diivi