[Issue 18743] ConditionalExpression and AssignExpression should require parentheses

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 8 20:04:52 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18743

Stefan <kdevel at vogtner.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kdevel at vogtner.de

--- Comment #5 from Stefan <kdevel at vogtner.de> ---
(In reply to David Nadlinger from comment #1)
>     (true ? (stt = "AA") : stt) = "BB",
> 
> in line with C and other languages, but notably not C++.

The value of the ternary conditional operator of C is not an l-value. Hence the
compilations fails (for a conforming compiler). JavaScript/ECMAScript follows
C++. C# does probably not allow a free ternary conditional. The only language I
found which behaves like D is perl.

--


More information about the Digitalmars-d-bugs mailing list