You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generic function: A function is generic when at least one of its arguments is generic, or when it returns a compile time only type
Generic argument: An argument is generic when it is comptime or anytype
Current behavior
In stage1, generic function type erasure works in the following way:
If any of the arguments is generic, all of the following arguments are type erased, as well as the return type (erased types are represented as anytype in the typename of the type of the generic function)
If no arguments are generic but the return type is a compile time only type, the return type is type erased.
Proposal
If none of the arguments are generic but the return type is comptime only, the function shall be marked as generic but the return type shall not be type erased.
When at least one of the arguments is generic, the following shall be applied to the rest of the arguments and the return type:
If the type expression contains any references to a preceding generic or type erased argument, the current argument or return type shall be type erased
Otherwise, the argument or return type shall remain unmodified
Reacted by Felix Queißner, Tadeo Kondrak, Ethernet, cryptocode, Mason Dean Kukosky and Jason Phan
@dbandstra This affects the type of generic fns, and in turn typeInfo and typeName, yes.
In this specific exzample @TypeOf(func) would become fn (u16, type, u32) void and the null values in typeInfo would get a concrete type value.
Activity
Rocknest commentedon Nov 6, 2020
I was thinking this behaviour is a bug
alexnask commentedon Nov 6, 2020
@dbandstra This affects the type of generic fns, and in turn typeInfo and typeName, yes.
In this specific exzample
@TypeOf(func)would becomefn (u16, type, u32) voidand the null values in typeInfo would get a concrete type value.cryptocode commentedon Feb 8, 2021
This would be great to get fixed, I have a use case where it's needed but am running into:
Vexu commentedon Jan 13, 2023
Implemented in self-hosted: