Skip to content

Commit

Permalink
fix enums, add preexisting bug tests
Browse files Browse the repository at this point in the history
  • Loading branch information
metagn committed Nov 9, 2024
1 parent 39a88ff commit 46af4dd
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/semtypinst.nim
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType, isInstValue = false):
if containsGenericType(t) or
# nominal types as direct generic instantiation values
# are re-instantiated even if they don't contain generic fields
(isInstValue and t.kind in {tyDistinct, tyEnum, tyObject}):
(isInstValue and t.kind in {tyDistinct, tyObject}):
#if not cl.allowMetaTypes:
bailout()
result = instCopyType(cl, t)
Expand Down
1 change: 1 addition & 0 deletions tests/destructor/tinvalid_rebind.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
discard """
disabled: true
joinable: false
cmd: "nim check $file"
errormsg: "cannot bind another '=destroy' to: Foo; previous declaration was constructed here implicitly: tinvalid_rebind.nim(12, 7)"
Expand Down
17 changes: 17 additions & 0 deletions tests/destructor/tinvalid_rebind_nonempty.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
discard """
disabled: true
joinable: false
cmd: "nim check $file"
errormsg: "cannot bind another '=destroy' to: Foo; previous declaration was constructed here implicitly: tinvalid_rebind.nim(12, 7)"
line: 14
"""

type
Foo[T] = object
x: T

proc main =
var f: Foo[int]

proc `=destroy`[T](f: var Foo[T]) =
discard
24 changes: 24 additions & 0 deletions tests/objects/tgenericsubtype.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
discard """
disabled: true
"""

# currently broken

block:
type
Foo[T] = object of RootObj
x: T
Bar = object of Foo[int]

proc foo(x: typedesc[Foo]) = discard

foo(Bar)

block:
type
Foo[T] = object of RootObj
Bar = object of Foo[int]

proc foo(x: typedesc[Foo]) = discard

foo(Bar)

0 comments on commit 46af4dd

Please sign in to comment.