-
-
Notifications
You must be signed in to change notification settings - Fork 209
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
DerefMut on Gd pointer may be used to break subtyping relations #23
Comments
164: Inject scene tree into `#[itest]` r=Bromeon a=Bromeon Also adds another test for `Gd::eq()` in the case of dead instances, and a stub for testing #23. Simplifies the proc-macro machinery further. bors r+ Co-authored-by: Jan Haller <[email protected]>
164: Inject scene tree into `#[itest]` r=Bromeon a=Bromeon Also adds another test for `Gd::eq()` in the case of dead instances, and a stub for testing #23. Simplifies the proc-macro machinery further. Co-authored-by: Jan Haller <[email protected]>
164: Inject scene tree into `#[itest]` r=Bromeon a=Bromeon Also adds another test for `Gd::eq()` in the case of dead instances, and a stub for testing #23. Simplifies the proc-macro machinery further. Co-authored-by: Jan Haller <[email protected]>
So the issue here is that while shared references are covariant, mutable references are invariant. So if we want our subtyping relationship to be correct, then we cannot implement So as i see it there are a couple of options here:
1 will require us to now reexamine our usage of 2 will require rewriting some functions (such as notification), and possibly worse ergonomics than currently. But it might not be too bad overall, hard to say without trying it. 3 will require a big rewrite, and it's a bit unclear what the best method of supporting subtyping then is. it's likely that we'd need more code duplication than currently. how much is unclear to me at the moment. traits with default methods and blanket impls seem feasible to me, but im not fully convinced of it. |
I went for approach 1) in the above list: we keep the behavior as-is, but do runtime checks + panics to prevent UB. Rationale: I was the one to originally bring up this scenario on Discord, and in more than a year of gdext usage, I haven't seen a single user reporting this problem. It's unlikely to happen in practice, and for the handful of cases where it may happen, runtime checks are good enough. We can disable them in Release mode. Why not enforce this via type system, by only providing With our declared focus on pragmatism, I believe retaining |
The following code snippet can be used to put an arbitrary
Node
into aGd<Node3D>
:The text was updated successfully, but these errors were encountered: