Skip to content

Interpreter is stricter than compiler in handling overloaded function-type keyword parameters #2621

@rodinaarssen

Description

@rodinaarssen

Consider the following module.

bool a(int _x) = true;
bool a(str _s) = true;

bool b(int _x) = false;
bool b(int _x, int _y) = false;

void foo(bool(int) f = b) { println(f(1)); }

void main() {
    hoi(f=a);   //executes, `a` is of type `bool(value)`
    hoi(f=b);   //throws UnexpectedType: "Expected bool (int), but got value"
}

The dynamic type of a is here bool(value); b is of type value.

The type checker accepts both statements in main, whereas the interpreter decides at run time that b is not acceptable for the keyword parameter f.

It is conceivable that the compiler is simply better equipped to decide that there is a valid overload of b; however, it would be ideal that the checker and interpreter are aligned.

Desktop (please complete the following information):

  • Context: VS Code extension 0.13.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions