On Monday, 27 August 2012 at 10:32:28 UTC, Manu wrote:
Because the two types were considered to be the same, only
different.
And how was that a problem? They never interacted in the
example, the
assignments were totally separate, they shouldn't have been
confused.
Just speculating, but it just looks like the type was
misrepresented when
it was looked up from a map by name or something, and matched
the wrong
cached definition... or something along those lines.
It looks like a bug exposed from implementation detail, I can't
see
anything in the bug report that shouldn't theoretically work
fine.
I seem to recall I looked at this issue myself at one point. It
goes something like:
----
auto foo = (int a = 1) { return a; };
auto bar = (int a) { return a; };
----
int function(int) is mangled exactly the same as int function(int
= 1) as default args aren't used for mangling. dmd does semantic
analysis on the type of foo, which returns int function(int = 1),
which is mangled as int function(int) and stored in dmd's hashmap
of types (default args aren't mangled). When the semantic
analysis of bar is done it checks the hashmap, sees that the type
is already there (has the same name mangling) and does not repeat
semantic analysis. If you switch the order of declarations then
the opposite happens - the default arg is ignored.