[Issue 339] New: Alias of function pointer type cannot be forward referenced

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Sep 10 10:05:30 PDT 2006


http://d.puremagic.com/issues/show_bug.cgi?id=339

           Summary: Alias of function pointer type cannot be forward
                    referenced
           Product: D
           Version: 0.166
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: smjg at iname.com


The following code fails to compile:

----------
uint[] data;

void benchmark(Algorithm alg) {
    alg(data);
}

alias void function(uint[]) Algorithm;
----------
D:\My Documents\Programming\D\Tests\bugs\function_forward1.d(4): forward
reference to type uint[]
----------

It took me a bit of work to figure what it was on about.  How can a built-in
type be forward referenced?  I then realised that the forward reference was in
fact to the Algorithm alias.

It turns out that the bug disappears if the parameter is uint rather than
uint[].

Although the error line pinpoints the line where the function is called, the
error still occurs if a use precedes the alias declaration but the call is
placed after it.  For example:

----------
uint[] data;

void benchmark(Algorithm alg) {
        test(alg);
}

alias void function(uint[]) Algorithm;

void test(Algorithm alg) {
        alg(data);
}
----------
D:\My Documents\Programming\D\Tests\bugs\function_forward2.d(10): forward
reference to type uint[]
----------


-- 




More information about the Digitalmars-d-bugs mailing list