Type-casting issue when providing a generic function as argument. #21132
Labels
Bug
This tag is applied to issues which reports bugs.
Generics[T]
Bugs/feature requests, that are related to the V generics.
Status: Confirmed
This bug has been confirmed to be valid by a contributor.
Unit: Checker
Bugs/feature requests, that are related to the type checker.
Unit: Compiler
Bugs/feature requests, that are related to the V compiler in general.
Describe the bug
I am not 100% shure if this is bug, but I am not able to create a function with another function (from a std library) as argument. In my opinion this should work, but everything I tried didnt. Ths snipped is the most basic one. I tried with setting the generic to "f64" (the error message than refers surprisingly to the module like "math.f64"), or try to cast the function type (more errors of course).
I hope that I have made a mistake, but this type of functions would be very helpfull to avoid unnecessary (escecially for lazy people like me).
Reproduction Steps
Code: https://play.vlang.io/p/0a82f72d9f
Expected Behavior
No error and the same result for "abs_oldstyle()" and "generic_new(math.abs)".
Current Behavior
Output:
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.5 872bcbc
Environment details (OS name and version, etc.)
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: