On 08/27/2012 05:48 AM, Robert Clipsham wrote:
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.
I had opened a related bug recently: http://d.puremagic.com/issues/show_bug.cgi?id=8579 Ali