digitalmars.D.bugs - [Issue 7585] New: functions in templates inferred as delegate
- d-bugmail puremagic.com (32/32) Feb 25 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7585
- d-bugmail puremagic.com (23/23) Feb 25 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7585
- d-bugmail puremagic.com (10/10) Feb 26 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7585
- d-bugmail puremagic.com (15/15) Feb 27 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7585
- d-bugmail puremagic.com (10/10) Feb 27 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7585
- d-bugmail puremagic.com (9/9) Feb 29 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7585
- d-bugmail puremagic.com (6/6) Feb 29 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7585
- d-bugmail puremagic.com (9/9) Feb 29 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7585
- d-bugmail puremagic.com (7/7) Jun 05 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7585
- d-bugmail puremagic.com (11/11) Jun 12 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7585
- d-bugmail puremagic.com (12/12) Feb 05 2013 http://d.puremagic.com/issues/show_bug.cgi?id=7585
- d-bugmail puremagic.com (13/17) Feb 05 2013 http://d.puremagic.com/issues/show_bug.cgi?id=7585
- d-bugmail puremagic.com (9/17) Feb 05 2013 http://d.puremagic.com/issues/show_bug.cgi?id=7585
- d-bugmail puremagic.com (8/23) Feb 05 2013 http://d.puremagic.com/issues/show_bug.cgi?id=7585
- d-bugmail puremagic.com (16/24) Feb 05 2013 http://d.puremagic.com/issues/show_bug.cgi?id=7585
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 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: -------
Feb 25 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7585 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: -------
Feb 25 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 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: -------
Feb 26 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7585 Ali Cehreli <acehreli yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |acehreli yahoo.com 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: -------
Feb 27 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 PST --- TDPL says that it's inferred. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 27 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7585 Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/65fe59384a05de9e59cda85f0de8296d6fc9c478 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: -------
Feb 29 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7585 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: -------
Feb 29 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7585 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: -------
Feb 29 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7585 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: -------
Jun 05 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7585 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 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: -------
Jun 12 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7585 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com 13:08:39 PST --- line which fails is: Callback cb3 = &Wrap!(f3); // NG -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 05 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7585 timon.gehr gmx.ch changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXEDline which fails is: Callback cb3 = &Wrap!(f3); // NGIt is to be expected that this fails. If the OP sample works, I assume this is fixed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 05 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7585 13:28:09 PST ---I guess he also expects this to fail then: Callback cb3 = &Wrap!((){}); // NG but it doesn't fail. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------line which fails is: Callback cb3 = &Wrap!(f3); // NGIt is to be expected that this fails. If the OP sample works, I assume this is fixed.
Feb 05 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7585This should work. What he wanted to show is that (){ } currently behaves like f3, while it should behave like f1 or f2. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------I guess he also expects this to fail then: Callback cb3 = &Wrap!((){}); // NG but it doesn't fail.line which fails is: Callback cb3 = &Wrap!(f3); // NGIt is to be expected that this fails. If the OP sample works, I assume this is fixed.
Feb 05 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7585 ---line which fails is: Callback cb3 = &Wrap!(f3); // NGCallback cb1 = &Wrap!(f1); // OK Callback cb2 = &Wrap!(f2); // OKThe Wrap function inside Wrap template is declared with extern(C). So it cannot have any hidden context pointer. And, calling f1 or f2 will not need such extra pointer, then Wrap!(f1) and Wrap!(f2) will succeed to compile.Callback cb3 = &Wrap!(f3); // NGf3 is a nested function. So the Wrap function should get a hidden context to main function, but it is impossible. Then the instantiation Wrap!(f3) will fail.Callback cb3 = &Wrap!((){}); // NGThis should be compiled. The lambda function (){} has no outer context access, so it should not be treated as nested. But, it had been accidentally done. As a conclusion, current compiler works as expected. This bug is already fixed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 05 2013