David Nadlinger <> changed:

           What    |Removed                     |Added
                 CC|                            |
           Hardware|x86_64                      |All
            Summary|Conditional expression      |ConditionalExpression and
                   |(ternary operator) can      |AssignExpression should
                   |evaluate the third          |require parentheses
                   |expression even "If it is   |
                   |true"                       |
                 OS|Linux                       |All
           Severity|normal                      |enhancement

--- Comment #1 from David Nadlinger <> ---
This isn't a bug.

In D, ?: has higher precedence than =, so

    true ? stt = "AA" : stt = "BB"


    (true ? (stt = "AA") : stt) = "BB",

in line with C and other languages, but notably not C++.

The operator precedence should be documented somewhere, though; while there is
a table in TDPL (p. 61 ff.) and on the Wiki
(, I can't seem to find it on


Changing this to an enhancement request, as we should really consider requiring
explicit parenthesization for this sort of error-prone code, similar to how we
disallow assignment expressions in if statements.


Reply via email to