-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type instantiation in result function types when using constructors as functions #1467
Comments
This passed the compiler's type checker. The interpreter, however, complains when I try to run it:
|
Interesting bug. Will have a look in January; can you manage a workaround in the mean time? |
The bug is caused by this line right here:
The code correctly returns the function as a result (this is a quick implementation), but in case of an instantiated abstract function, the type will not be instantiated in this case resulting in incorrect information loss. |
|
The second bug is caused by this line in vallang: https://github.com/usethesource/vallang/blob/f1a159feda1e13e09d9e581d17f29f1513917717/src/main/java/io/usethesource/vallang/type/AbstractDataType.java#L418 |
More fun: self-applying
|
The current state is that self-application of curry is not possible yet. The root cause is a very basic (and wrong) assumption in the code of the interpreter: for functions (closures and/or generic or otherwise) the static type is equal to their dynamic type. This is because each function instance extends |
…latest fixes in vallang, towards fixing #1467
Let's say we have the following module:
At the prompt I can do
f = curry(sum, 1)
, which results in:The return type, should be
int(int)
I guess, but callingf(2)
correctly evaluates to3
.But calling curry on a constructor, leads to an exception:
So I think there are two problems, but it's unclear to me if and if so, how, they are related:
The text was updated successfully, but these errors were encountered: