Skip to content

Commit

Permalink
include static types in type bound ops (#24366)
Browse files Browse the repository at this point in the history
  • Loading branch information
metagn authored Oct 26, 2024
1 parent efd603e commit 40fc2d0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 1 addition & 2 deletions compiler/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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`?
Expand Down
8 changes: 8 additions & 0 deletions tests/sandwich/mstatic.nim
Original file line number Diff line number Diff line change
@@ -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 changes: 5 additions & 0 deletions tests/sandwich/tstatic.nim
Original file line number Diff line number Diff line change
@@ -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)"

0 comments on commit 40fc2d0

Please sign in to comment.