mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-07 13:33:22 +00:00
include static types in type bound ops (#24366)
refs https://github.com/nim-lang/Nim/pull/24315#discussion_r1816332587
This commit is contained in:
@@ -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`?
|
||||
|
||||
8
tests/sandwich/mstatic.nim
Normal file
8
tests/sandwich/mstatic.nim
Normal 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 & ")"
|
||||
5
tests/sandwich/tstatic.nim
Normal file
5
tests/sandwich/tstatic.nim
Normal 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)"
|
||||
Reference in New Issue
Block a user