Skip to content

[BUG] Function redefinition does not throw error #481

@frankhart2018

Description

@frankhart2018

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingeasyEasy problem

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions