Bug 9398 – Wrong diagnostic for ternary operator type mismatch
Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-01-25T21:47:00Z
Last change time
2013-01-27T01:00:06Z
Keywords
diagnostic, pull
Assigned to
andrej.mitrovich
Creator
kekeniro2
Comments
Comment #0 by kekeniro2 — 2013-01-25T21:47:12Z
Error message showing type mismatch for
(a ? b : c)
is printed below:
Error: incompatible types for ((b) ? (c)): 'B' and 'C'
Wrong '?' position.
It shoud be ... ((a) ? (b) : (c)): 'B' and 'C'
Comment #1 by andrej.mitrovich — 2013-01-26T12:57:32Z
Comment #2 by andrej.mitrovich — 2013-01-26T13:00:58Z
(In reply to comment #0)
> It should be ... ((a) ? (b) : (c)): 'B' and 'C'
Nope, it should be:
> ((b) : (c)): 'B' and 'C'
Otherwise you can't determine what position 'B' and 'C' are in because the ternary expression could be quite complex, e.g.:
> ((a) ? (a) : (b) ? (b) : (c)): 'int' and 'float'
Comment #3 by github-bugzilla — 2013-01-26T14:50:09Z