I'm trying to create a proc that returns a custom tuple that contains a single element that is a proc type i.e.
type
CustomTuple = tuple
foo: proc(input: int): int
proc createCustomTuple(): CustomTuple =
(foo: proc(input: int): int = 10)
However, when I compile this I get the following error (I am compiling with Nim Version 1.2.6 on Windows).
Error: type mismatch: got <tuple[foo: proc (input: int): int{.noSideEffect, gcsafe, locks: 0.}]> but expected 'CustomTuple = tuple[foo: proc (input: int): int{.closure.}]'
So the compiler thinks I am returning a regular tuple and not a CustomTuple
but I have no idea how to change this to make it work. The documentation for tuples in the Nim manual show custom tuples being constructed in the way that I am doing it and I couldn't find any examples of returning a custom tuple from a proc.
If I change my CustomTuple
definition to contain types that aren't procs then it compiles successfully so it appears it has something to do my custom tuple containing a proc that is causing this to fail to compile.
Can anyone explain why the above code is not compiling?