-
-
Notifications
You must be signed in to change notification settings - Fork 701
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
Fix Bugzilla 22293: opCast!bool for Nullable #9039
Conversation
Thanks for your pull request and interest in making D better, @pbackus! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + phobos#9039" |
If I'm reading this right, the cast that's failing is I think maybe the right solution here is for the compiler to fall back to built-in |
Further examination reveals that the D compiler will let you cast between more or less any two types as long as they're the same size: struct A { ubyte[8] x; }
struct B { int* p; }
static assert(A.sizeof == B.sizeof);
void main()
{
A a;
auto b = cast(B) a;
} So I guess the correct template constraint for the second |
The second opCast overload is necessary to allow built-in implicit conversions (e.g., mutable to const) to be performed explicitly via a cast expression. Nullable.opEquals depends on this behavior.
LDC build error appears to be transient (didn't happen the first time); force-pushing to re-run. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As much as I hate this opCast boiler plate, it appears to be necessary.
The second opCast overload is necessary to allow built-in implicit conversions (e.g., mutable to const) to be performed explicitly via a cast expression. Nullable.opEquals depends on this behavior.
The second opCast overload is necessary to allow built-in implicit conversions (e.g., mutable to const) to be performed explicitly via a cast expression. Nullable.opEquals depends on this behavior.
The second opCast overload is necessary to allow built-in implicit conversions (e.g., mutable to const) to be performed explicitly via a cast expression. Nullable.opEquals depends on this behavior.