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

Cannot inherit from generic forward types #24446

Open
metagn opened this issue Nov 17, 2024 · 0 comments
Open

Cannot inherit from generic forward types #24446

metagn opened this issue Nov 17, 2024 · 0 comments

Comments

@metagn
Copy link
Collaborator

metagn commented Nov 17, 2024

Split from #18861

type
  ConnectionRequest* = ref object of RootObj
  ConnectionStrBool* = distinct bool
  ConnectionSetRequest = ref object of ConnectionRequestT[ConnectionStrBool]
  ConnectionRequestT*[T] = ref object of ConnectionRequest
proc execute*(req: ConnectionRequestT[bool]) = discard
proc execute*(req: ConnectionRequestT[ConnectionStrBool]) = discard
ConnectionSetRequest().execute()

Apparently used to give this error:

/tmp/zzz.nim(4, 37) Error: inheritance only works with non-final objects; for ConnectionRequestT[zzz.ConnectionStrBool] to be inheritable it must be 'object of RootObj' instead of 'object', but swapping object declaration order into 

But now segfaults the compiler in lookupInRecordAndBuildCheck called here.

This case also used to not compile:

type
  Foo = object of Bar
  Bar = object of RootObj

and now compiles, but might not work if Foo is used further.

#5687 might be related

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

1 participant