Skip to content

Multiple functions with the same name and argument types are allowed by the type checker #2883

Description

@rodinaarssen

Describe the bug

The type checker currently does not flag the existence of the following two functions within the same module as an error, whereas overloading solely by return type is not allowed.

str f(node _) = "";
int f(node _) = 1;

The interpreter seems to use the function that is defined first. When importing a module with the above declarations and the following two, the interpreter signals a type error but the module imports fine anyway. Using the variable i results in an UninitalizedVariable error.

public int i = f(""());
void p() { println(i); }
rascal>import BB;
[ERROR] |file:///C:/Users/Rodin/test-project/BB.rsc|(116,11,<10,11>,<10,22>):10:11: Expected int, but got str
Advice: |https://www.rascal-mpl.org/docs/Rascal/Errors/CompileTimeErrors/UnexpectedType|

ok
rascal>i
|prompt:///|(0,1,<1,0>,<1,1>): Uninitialized variable: i
Advice: |https://www.rascal-mpl.org/docs/Rascal/Errors/CompileTimeErrors/UninitializedVariable|

Desktop (please complete the following information):

  • VS Code 0.13.6-head4430 (with Rascal 0.43.0-RC14)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions