diff --git a/compiler/types.nim b/compiler/types.nim index 8ac3ff52f791..a6694ab26ac2 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -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`? diff --git a/tests/sandwich/mstatic.nim b/tests/sandwich/mstatic.nim new file mode 100644 index 000000000000..b07d339d5be9 --- /dev/null +++ b/tests/sandwich/mstatic.nim @@ -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 & ")" diff --git a/tests/sandwich/tstatic.nim b/tests/sandwich/tstatic.nim new file mode 100644 index 000000000000..82ae607fc2dc --- /dev/null +++ b/tests/sandwich/tstatic.nim @@ -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)"