D-Programming-Language/druntime — comment on commit 3159f6f49c2c06d0cc714538692f2026c831b8ab
File: src/object_.d line 1845
By complexmath:

On Jan 4, 2012, at 3:09 PM, Brad Roberts wrote:

> It's clearly broken, as Walter reported:
>
> src/rt/minfo.d(207): Error: function rt.minfo.rt_moduleCtor.runModuleFuncs!(__lambda210).runModuleFuncs is a nested function and cannot be accessed from _moduleCtor
> src/rt/minfo.d(207): Error: function rt.minfo.rt_moduleCtor.runModuleFuncs!(__lambda212).runModuleFuncs is a nested function and cannot be accessed from _moduleCtor

Um, what? Here's the relevant code (in rt/minfo.d):

extern (C) void rt_moduleCtor()
{
_moduleinfo_array = getModuleInfos();
_sortedCtors = sortCtors(_moduleinfo_array);

// run independent ctors
runModuleFuncs!((a) { return a.ictor; })(_moduleinfo_array);
// sorted module ctors
runModuleFuncs!((a) { return a.ctor; })(_sortedCtors._ctors);
// flag all modules as initialized
foreach (m; _moduleinfo_array)
m.flags = m.flags | MIctordone;
}

// NOTE: This is to preserve compatibility with the Windows DLL sample.
extern (C) void _moduleCtor()
{
rt_moduleCtor();
}

All I did was add the _moduleCtor() function above. This looks like a bug in DMD's inlining mechanism. I guess what I'll do to fix is move _moduleCtor() out of minfo.d so the call to rt_moduleInfo() is opaque.