www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9971] New: eponymous function is not an lvalue

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

           Summary: eponymous function is not an lvalue
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: ellery-newcomer utulsa.edu



15:56:31 PDT ---
the code:

void main() {
    goo!()();
}

void goo()() {
    auto g = &goo; // not ok
}
void goo2() {
    auto g = &goo2; // ok
}

the fireworks:

Error: goo()() is not an lvalue

dmd 2.063-devel.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 20 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9971


Maxim Fomin <maxim maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim maxim-fomin.ru



---
I think it does not work because &goo is address of raw template and dmd does
not instantiate it, so you should use pointer to instantiated function. I am
not sure this is bug (but it may be an enhancement request).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9971




22:17:10 PDT ---

 I think it does not work because &goo is address of raw template and dmd does
 not instantiate it, so you should use pointer to instantiated function. I am
 not sure this is bug (but it may be an enhancement request).
It is inconsistent with the way templated structs and classes work: void main() { alias T!(int) t1; } struct T(j) { pragma(msg, "a struct ",T); // T is the struct } pragma(msg, "a template ", T); // T is the template -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9971




---

 It is inconsistent with the way templated structs and classes work:
 
 void main() {
     alias T!(int) t1;
 }
 
 struct T(j) {
     pragma(msg, "a struct ",T); // T is the struct
 }
 pragma(msg, "a template ", T); // T is the template
Sorry I don't see your point. Note, that second message is printed irrespective to instantiation and none of the messages is sensitive to what T is really is. void main() { alias T!(int) t1; } struct T(j) { //pragma(msg, "a struct ",T); // T is the struct pragma(msg, T.stringof); } //pragma(msg, "a template ", T); // T is the template pragma(msg, T.stringof); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9971




22:45:05 PDT ---

 
 Sorry I don't see your point. Note, that second message is printed irrespective
 to instantiation and none of the messages is sensitive to what T is really is.
My point is that inside the struct template, T without any template instantiation refers to the instantiated struct: import std.traits; void main() { alias T!(int) t1; } struct T(j) { T foo() { T t; return t; } } static assert(is(ReturnType!(T!int.foo) == T!int)); static assert(is(ReturnType!(T!double.foo) == T!double)); But in a templated function, T refers to the template: -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9971


deadalnix <deadalnix gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |deadalnix gmail.com




 I think it does not work because &goo is address of raw template and dmd does
 not instantiate it, so you should use pointer to instantiated function. I am
 not sure this is bug (but it may be an enhancement request).
No, within the function, the function must be resolve before the template. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9971




I think this is a bug.
Inside template function, the name 'goo' should be resolved to the instantiated
function 1st, then rewritten to template 'goo' if needed.

For example, this code should work.

void main() {
    goo(1);                // 1. instantiate goo!int
}
void goo(T...)(T args) {
    auto g = &goo;         // 2. &goo!int == void function(int)
                           // 4. &goo!() == void function()
    pragma(msg, typeof(g));
    static if (T.length)
        goo(args[1..$]);   // 3. instantiate goo!()
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9971




---
Yes, you are both right.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9971


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid



https://github.com/D-Programming-Language/dmd/pull/1970

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 06 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9971




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/f34c77f6f19ea516c19842f2aff0e43a7d94c3ef
fix Issue 9971 - eponymous function is not an lvalue

https://github.com/D-Programming-Language/dmd/commit/654de7808e89204d20bac6f7f228fe07e3dd2c7a


Issue 9971 - eponymous function is not an lvalue

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 06 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9971


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 06 2013