[Issue 10926] Wrong expression printed when ternary operator used as lvalue

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 12 10:15:01 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=10926



--- Comment #4 from yebblies <yebblies at gmail.com> 2013-11-13 05:14:59 EST ---
(In reply to comment #3)
> (In reply to comment #2)
> > No rejects-valid here, it simply prints the wrong expression.
> > 
> > https://github.com/D-Programming-Language/dmd/pull/2750
> 
> Please help me understand. This is a reduced test code:
> 
> 
> void main() {
>     const(int)[] a;
>     int[] c;
>     (true ? a : c) ~= 20;
> }
> 
> 
> Before this fix it gave:
> temp.d(4): Error: a is not an lvalue
> 
> Now it gives:
> temp.d(4): Error: cast(const(int)[])c is not an lvalue
> 
> How is the error message improved? c is a fully mutable array.
> 
> Why isn't this output a rejects-valid still? Both a and c can be appended. The
> common type between a and c should be const(int)[], that is appendable.
> 
> (If I receive no good answer I'll reopen this issue later.)

c can be appended to, but cast(const(int)[])c cannot, because it is an rvalue.

Would this make any sense?

(cast(const(int)[])c) ~= 20;

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list