fix issue 20138 - is expression not evaluating correctly?#10317
fix issue 20138 - is expression not evaluating correctly?#10317dlang-bot merged 4 commits intodlang:masterfrom
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.
Suggest adding static assert(is(inout const S U == inout U) && is(U == const shared S));
There was a problem hiding this comment.
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.
My guess is that it's handled by
deduceTypeHelper, which isn't even called forisexpressions.
That was supposed to be: My guess is that it's handled by deduceWildHelper
There was a problem hiding this comment.
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 Tinto ashared Uparameter, then no constconversion is needed to infer
Uasconst int. Same withinout intandinout const int.