Jump to page: 1 2
Thread overview
[Issue 7585] New: functions in templates inferred as delegate
Feb 25, 2012
simendsjo
Feb 26, 2012
Kenji Hara
Feb 26, 2012
Kenji Hara
Feb 28, 2012
Ali Cehreli
Feb 28, 2012
Jonathan M Davis
Feb 29, 2012
Ali Cehreli
Jun 05, 2012
Kenji Hara
Feb 05, 2013
Andrej Mitrovic
Feb 05, 2013
timon.gehr@gmx.ch
Feb 05, 2013
Andrej Mitrovic
Feb 05, 2013
timon.gehr@gmx.ch
Feb 06, 2013
Kenji Hara
February 25, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7585

           Summary: functions in templates inferred as delegate
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: simendsjo@gmail.com


--- Comment #0 from simendsjo <simendsjo@gmail.com> 2012-02-25 09:22:34 PST ---
extern(C) alias void function() Callback;

template Wrap(alias dg)
{
    extern(C) void Wrap()
    {
        dg();
    }
}

void main()
{
    Callback cb = &Wrap!( () {} );
}

Error: cannot implicitly convert expression (&Wrap) of type void delegate()
pure nothrow @safe to extern (C) void function()

According to Timon Gehr: "'() {}' should be inferred as void function()pure
nothrow @safe." http://forum.dlang.org/post/jib1a2$1jl5$1@digitalmars.com

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 26, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7585



--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2012-02-25 20:21:04 PST ---
The root cause is conservative escape analysis for nested template instantiation.

extern(C) alias void function() Callback;

template Wrap(alias dg)
{
    extern(C) void Wrap() { dg(); }
}

void f1(){}

void main()
{
    static void f2(){}
    void f3(){}

    Callback cb1 = &Wrap!(f1);      // OK
    Callback cb2 = &Wrap!(f2);      // OK
    Callback cb3 = &Wrap!(f3);      // NG
    Callback cb3 = &Wrap!((){});    // NG
}

Current implementation always treats lambda literal as nested symbol.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 26, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7585


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

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


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2012-02-26 07:43:34 PST ---
https://github.com/D-Programming-Language/dmd/pull/767

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 28, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7585


Ali Cehreli <acehreli@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |acehreli@yahoo.com


--- Comment #3 from Ali Cehreli <acehreli@yahoo.com> 2012-02-27 16:46:03 PST ---
I would hate to stop the implementation of a useful feature, but isn't this against the current spec?

  http://dlang.org/expression.html#FunctionLiteral

"If the keywords function or delegate are omitted, it defaults to being a delegate."

Ali

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 28, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7585


Jonathan M Davis <jmdavisProg@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg@gmx.com


--- Comment #4 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-02-27 16:56:33 PST ---
TDPL says that it's inferred.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 29, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7585



--- Comment #5 from github-bugzilla@puremagic.com 2012-02-29 12:19:43 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/65fe59384a05de9e59cda85f0de8296d6fc9c478 Merge pull request #767 from 9rnsr/fix7585

Issue 7585 - functions in templates inferred as delegate

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 29, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7585



--- Comment #6 from Ali Cehreli <acehreli@yahoo.com> 2012-02-29 13:15:41 PST ---
Just a reminder: the spec needs to be updated.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 29, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7585



--- Comment #7 from github-bugzilla@puremagic.com 2012-02-29 15:22:33 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/181fb9cd10cf11f20feb22ee13e305f41f9cbe90 Revert "fix Issue 7585 - functions in templates inferred as delegate"

This reverts commit 182edee285f9c7b8c552e5de3c11636aac154991.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 05, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7585



--- Comment #8 from Kenji Hara <k.hara.pg@gmail.com> 2012-06-05 07:41:29 PDT ---
A new pull to retry fixing: https://github.com/D-Programming-Language/dmd/pull/982

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 12, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7585



--- Comment #9 from github-bugzilla@puremagic.com 2012-06-12 10:06:25 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/24b83f373e93fc553e42213132adabb992c03405 fix Issue 7585 - functions in templates inferred as delegate

https://github.com/D-Programming-Language/dmd/commit/c66af72bd96110c027db69ea560b6dc3f88b3054 Merge pull request #982 from 9rnsr/fix7585

Issue 7585 - functions in templates inferred as delegate

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2