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