Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken finializer binding for distinct refs #19138

Open
alaviss opened this issue Nov 13, 2021 · 0 comments
Open

Broken finializer binding for distinct refs #19138

alaviss opened this issue Nov 13, 2021 · 0 comments

Comments

@alaviss
Copy link
Collaborator

alaviss commented Nov 13, 2021

Example

type
  SocketObj = object

  Socket = ref SocketObj

  AsyncSocketObj = distinct SocketObj

  AsyncSocket = ref AsyncSocketObj

proc `=destroy`(s: var SocketObj) =
  echo "Destroying Socket"

proc `=destroy`(s: var AsyncSocketObj) =
  echo "Destroying AsyncSocket"

proc newSocket(): Socket = Socket()
proc newAsyncSocket(): AsyncSocket = AsyncSocket(newSocket())

proc main() =
  var x = newSocket()
  var y = newAsyncSocket()

  x = nil
  y = nil

  GC_fullCollect()

main()

Current Output

Destroying Socket
Destroying Socket

Expected Output

Destroying Socket
Destroying AsyncSocket

Additional Information

  • Behaves correctly with --gc:arc
  • Found during development of nim-sys
$ nim -v
Nim Compiler Version 1.7.1 [Linux: amd64]
Compiled at 2021-11-08
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: 83a9c3ba31d180cd5e31026d8b7603bf7adea18c
active boot switches: -d:release -d:nimUseLinenoise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants