Hi, I try to use a ref to a tuple type, but I'm getting an error which I don't understand: Error: () must have a tuple type. An example code:
type MyTuple = tuple
a: string
b: int
proc newMyTuple(a: string, b: int): ref MyTuple =
new(result)
result[] = (a, b)
const t = newMyTuple("aa", 7)
How can I make it work?
Since it is a bug,...
It is not a bug. You cannot use reference types in expressions executed at compile time. From Nim's official documentation:
Restrictions on Compile-Time Execution
Nim code that will be executed at compile time cannot use the following language features:
methods
closure iterators
the cast operator
reference (pointer) types
the FFI