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 issue 20138 - is expression not evaluating correctly? #10317
Conversation
When passing a `shared const T` into a `shared U` parameter, then no const conversion is needed to infer `U` as `const int`. Same with `inout int` and `inout const int`.
Thanks for your pull request and interest in making D better, @aG0aep6G! 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
|
I don't know how to review this... |
PR to prepare Phobos for this fix: dlang/phobos#7147 |
For reference, dlang/druntime#2739 seems to be blocked by this. |
It seems to me this fix only deals with |
Right. Added those cases. |
Phobos PR merged. |
Force rebuild? |
alias S = shared int; | ||
static assert(is(const(S) U == const U) && is(U == shared int)); | ||
static assert(is(inout(S) U == inout U) && is(U == shared int)); | ||
static assert(is(inout(const S) U == inout(const U)) && is(U == shared int)); |
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.
Suggest adding static assert(is(inout const S U == inout U) && is(U == const shared S));
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.
Suggest adding
static assert(is(inout const S U == inout U) && is(U == const shared S));
I'd rather leave that out for now, because it's less obvious how to handle it.
For the others, I just changed MATCH.constant
to MATCH.exact
. For this combination, deduceTypeHelper
currently returns MATCH.nomatch
. But it works in IFTI, so there must be something else going on. My guess is that it's handled by deduceTypeHelper
, which isn't even called for is
expressions.
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.
My guess is that it's handled by
deduceTypeHelper
, which isn't even called foris
expressions.
That was supposed to be: My guess is that it's handled by deduceWildHelper
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.
I was gonna say we could do something like this:
*at = t.mutableOf().unSharedOf();
if ((t.mod & MODFlags.const_) && !(tParam.mod & MODFlags.const_))
*at = (*at).constOf();
if ((t.mod & MODFlags.shared_) && !(tParam.mod & MODFlags.shared_))
*at = (*at).sharedOf();
if ((t.mod & MODFlags.immutable_) && !(tParam.mod & MODFlags.immutable_))
*at = (*at).immutableOf();
if ((t.mod & MODFlags.wild) && !(tParam.mod & MODFlags.wild))
*at = (*at).wildOf();
However, apparently calling sharedOf()
on a const
type doesn't return a const shared
type, and likewise for the other *Of()
s. This somewhat disappoints me.
I'm not sure if it's really necessary to mention this in the changelog, but @thewilsonator has requested an entry, so I've added one. |
Is this good? |
Thanks. I wanted it because this is a non-obvious change of behaviour that would be better documented than not. It probably won't break anyones code, but, OTOH it did require a change in phobos. |
When passing a
shared const T
into ashared U
parameter, then no constconversion is needed to infer
U
asconst int
. Same withinout int
andinout const int
.