The return type is type because you are duping T which is a type.
If you want to clone a value, then you also need to pass a value to the function.
Secondly dupe only works on slices. Instead you can use create and copy manually.
If you try to use a generic function as function pointer at run time (neither const nor comptime) you get an error message like this:
temp10.zig:25:15: error: variable of type '*const fn (mem.Allocator, anytype) anytype' must be const or comptime
var fptr: @TypeOf(&toPtr) = undefined;
^~~~~~~~~~~~~~~
temp10.zig:25:15: note: function is generic
But it seems that you can use generic function pointers (that use anytype) when they are const or comptime, but I am not sure if I fully understand how these behave, I haven’t really used them before.
❯ zig build test --summary all
test
└─ run test
└─ zig test Debug native 1 errors
/Users/joelr/.cache/zig/p/1220b35238ee469fbef939a140f782abc024ff70cb0d8da6b9b8c20b3852991b812a/mecha.zig:68:36: error: unable to unwrap null
.@"fn" => |f| f.return_type.?,
~~~~~~~~~~~~~^~
/Users/joelr/.cache/zig/p/1220b35238ee469fbef939a140f782abc024ff70cb0d8da6b9b8c20b3852991b812a/mecha.zig:481:35: note: called from here
const return_type = ReturnType(P);
~~~~~~~~~~^~~
/Users/joelr/.cache/zig/p/1220b35238ee469fbef939a140f782abc024ff70cb0d8da6b9b8c20b3852991b812a/mecha.zig:495:32: note: called from here
) Parser(ReturnTypeErrorPayload(@TypeOf(conv))) {
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
src/sleigh.zig:49:17: note: called from here
.convert(toPtr)