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 cast ref to RootRef in Arc/Orc #20016

Closed
ringabout opened this issue Jul 13, 2022 · 4 comments
Closed

cannot cast ref to RootRef in Arc/Orc #20016

ringabout opened this issue Jul 13, 2022 · 4 comments

Comments

@ringabout
Copy link
Member

ringabout commented Jul 13, 2022

type
  Color = ref object

var x = Color()
let y = cast[RootRef](x)

errors expression cannot be cast to RootRef=ref RootObj in Arc/Orc

ref #19972

@ringabout
Copy link
Member Author

It makes https://github.com/yglukhov/nimsl fail.

@ringabout
Copy link
Member Author

It seems that ref object cannot cast to RootRef unless it inherits from RootObj or RootRef with arc/orc.

In this case nimsl tries to cast TableRef to RootRef, however TableRef is a final object.

@ringabout ringabout mentioned this issue Jul 13, 2022
6 tasks
@ringabout
Copy link
Member Author

Workaround:

type
  Color = ref object

var x = Color()
let y = cast[pointer](x)
# use Gc_ref(y) when it is needed

@ringabout ringabout closed this as not planned Won't fix, can't repro, duplicate, stale Sep 6, 2022
@ringabout
Copy link
Member Author

Workaround:

type
  Color = ref object

var x = Color()
let y = cast[pointer](x)
# use Gc_ref(y) when it is needed

This was referenced Sep 6, 2022
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