Skip to content

Conversation

elcritch
Copy link
Contributor

@elcritch elcritch commented Jan 7, 2025

Adds an error message for this situation. It's possibly due to a compiler bug but it's easy to workaround in user code by adding a destructor once you know what's causing the issue.

What triggers this is a type that has a cursor in it. This error only shows up with Nim binaries built by Nimble which seem to have asserts enabled.

type WeakRef*[T] {.acyclic.} = object
  ## type alias descring a weak ref that *must* be cleaned up
  ## when it's actual object is set to be destroyed
  pt* {.cursor.}: T

I suspect the cursor bit combined with sink causes this error.

However, I can work around with this:

proc `=destroy`*[T](obj: WeakRef[T]) =
  discard

@Araq
Copy link
Member

Araq commented Jan 8, 2025

Why not fix the compiler instead to allow for this case?

@elcritch
Copy link
Contributor Author

elcritch commented Jan 8, 2025

Why not fix the compiler instead to allow for this case?

I would but I don't really know my way around. Especially for something like cursor. Not sure where to begin. :)

@Araq
Copy link
Member

Araq commented Jan 8, 2025

Well isn't the solution here that "type contains ref" shall be false for "type contains a .cursor field with ref".

@elcritch
Copy link
Contributor Author

elcritch commented Jan 8, 2025

Well isn't the solution here that "type contains ref" shall be false for "type contains a .cursor field with ref".

Hmmm, yeah I'll take a crack at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants