evaluate forward referenced alias in correct scope
text/plain
1486
Comments
Comment #0 by dlang-bugzilla — 2007-12-14T19:28:44Z
// == minimal testcase start ==
alias uint DWORD;
MY_API_FUNCTION lpStartAddress; // <-- comment this line to remove error
extern (Windows) alias DWORD function(void*) MY_API_FUNCTION;
static assert(MY_API_FUNCTION.stringof == "uint(Windows *)(void*)");
// == minimal testcase end ==
The actual calling convention (MY_API_FUNCTION.stringof) is "uint(*)(void*)".
This is from a real-life case (the Windows header project).
Comment #1 by dfj1esp02 — 2009-04-06T06:05:43Z
For dmd 2.023
alias uint DWORD;
MY_API_FUNCTION lpStartAddress; // <-- comment this line to remove error
extern (Windows) alias DWORD function(void*) MY_API_FUNCTION;
static assert(MY_API_FUNCTION.stringof == "uintWindows function(void*)", MY_API_FUNCTION.stringof);
Comment #2 by dfj1esp02 — 2009-04-06T06:10:18Z
Subtle and disastrous bug, raising severity.
Comment #3 by r.sagitario — 2009-09-23T14:03:37Z
Created attachment 465
evaluate forward referenced alias in correct scope
The forward reference to the alias causes its semantic analysis to be run from the scope of the variable declaration, omitting the "extern(Windows)" attribute. The patch uses the scope of the symbol (which happens to already exist) instead of the current scope.
The patch also fixes the bad spacing "uintWindows".
Comment #4 by r.sagitario — 2009-09-23T14:04:11Z
the patch is against dmd 2.032
Comment #5 by clugdbug — 2009-09-24T00:23:59Z
You're a legend! This was on my list of ten most worst bugs in DMD.