www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8653] New: cannot take address of auto-return function declared in outside module: "Error: forward reference"

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8653

           Summary: cannot take address of auto-return function declared
                    in outside module: "Error: forward reference"
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: thelastmammoth gmail.com



See the following code for CT error.
It seems we cannot take address of auto-return function declared in outside
module, but we can if it's declared in the same module. 
The CT error is: "Error: forward reference"


file main.d:
----
import fun;

void run3(Fun,T...)(Fun fun,T args){
    fun(args);
}

class A1{
    void fun1(double x){
    }
    double fun2(double x){
        return x;
    }
    auto fun3(double x){
        return x;
    }
    auto fun4(double x){
    }
}

void main(){
    test1;
    test2;
}
void test1(){
    auto a=new A1;
    run3(&a.fun1,1);
    run3(&a.fun2,1);
    run3(&a.fun3,1);
    run3(&a.fun4,1);
}

void test2(){
    auto a=new A2;
    run3(&a.fun1,1);
    run3(&a.fun2,1);
    run3(&a.fun3,1);//CT error
    run3(&a.fun4,1);//CT error
}


-----

file fun.d:
----
module fun;

class A2{
    void fun1(double x){
    }
    double fun2(double x){
        return x;
    }
    auto fun3(double x){
        return x;
    }
    auto fun4(double x){
    }
}
----

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 13 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8653


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE



This is a dup of bug 5933.
I've already posted a pull request for that, but not yet merged.

*** This issue has been marked as a duplicate of issue 5933 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 15 2012