Open guzba opened 7 months ago
Elegantbeef pointed out that generics present a problem for the custom pragma approach used by Sunny for the Go-like field tags. Some notes:
type JsonField[S: static string] = distinct S type MYType[T] = object x: T proc jsonName(_: typedesc[MyType], _: JsonField["x"]): string = "Real name"
In the above example you cannot do x {.json: "MYJsonName".}: T As the pragma is lost in generic ast
import std/macros template myPragma() {.pragma.} type MyType[T] = object x: T var a = MyType[int](x: 100) assert not a.x.hasCustomPragma(myPragma)
From Discord as a last resort https://discord.com/channels/371759389889003530/371759389889003532/1214810826859487283
https://forum.nim-lang.org/t/11171
Elegantbeef pointed out that generics present a problem for the custom pragma approach used by Sunny for the Go-like field tags. Some notes:
In the above example you cannot do x {.json: "MYJsonName".}: T As the pragma is lost in generic ast
From Discord as a last resort https://discord.com/channels/371759389889003530/371759389889003532/1214810826859487283