include static types in type bound ops (#24366)

refs https://github.com/nim-lang/Nim/pull/24315#discussion_r1816332587
This commit is contained in:
metagn
2024-10-26 18:49:02 +03:00
committed by GitHub
parent efd603eb28
commit 40fc2d0e76
3 changed files with 14 additions and 2 deletions

View File

@@ -1993,8 +1993,7 @@ proc nominalRoot*(t: PType): PType =
#result = nominalRoot(t.skipModifier)
result = nil
of tyStatic:
# ?
result = nil
result = nominalRoot(t.base)
else:
# skips all typeclasses
# is this correct for `concept`?

View File

@@ -0,0 +1,8 @@
type Foo* = object
x*, y*: int
proc `$`*(x: static Foo): string =
"static Foo(" & $x.x & ", " & $x.y & ")"
proc `$`*(x: Foo): string =
"runtime Foo(" & $x.x & ", " & $x.y & ")"

View File

@@ -0,0 +1,5 @@
from mstatic import Foo
doAssert $Foo(x: 1, y: 2) == "static Foo(1, 2)"
let foo = Foo(x: 3, y: 4)
doAssert $foo == "runtime Foo(3, 4)"