that is bug?
David Nadlinger
code at klickverbot.at
Sat Apr 7 22:08:50 UTC 2018
On Saturday, 7 April 2018 at 09:07:48 UTC, sdvcn wrote:
> true?stt="AA":stt="BB"; <<<<-----///Out:BB
> writeln(stt);
As I just pointed out in Ali's bug report [1], this is correct, as
true ? stt = "AA" : stt = "BB"
means
(true ? (stt = "AA") : stt) = "BB",
in accordance to D's grammar [2]:
AssignExpression:
ConditionalExpression
ConditionalExpression = AssignExpression
[…]
We should probably require explicit parentheses here. Relying on
this behaviour is just asking for trouble anyway, as evidenced by
the amount of confusion in this thread.
— David
[1] https://issues.dlang.org/show_bug.cgi?id=18743
[2] https://dlang.org/spec/expression.html#assign_expressions
More information about the Digitalmars-d
mailing list