[Issue 12454] Return type inference does not work
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Mar 24 13:52:55 PDT 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12454
--- Comment #1 from Adam D. Ruppe <destructionator at gmail.com> 2014-03-24 13:52:52 PDT ---
D doesn't allow overloading on the return type, only on argument types. The
reason is that it would be difficult to figure out which one you want:
auto a = deduceRetType(); // which one?
int a = 10 + deduceRetType(); // which one?
Those could arguably be ambiguous errors or the second one might say string
doesn't make sense, so use int, but that's not how D works; an expression's
type is always known by looking at the expression itself without considering if
it works in context or not.
(if it doesn't work in context, that's when a compile error for mismatched type
is triggered)
--
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