Skip to content

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

@frankhart2018

Description

@frankhart2018

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmoderateModerate problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions