www.digitalmars.com         C & C++   DMDScript  

D.gnu - [Issue 1492] New: With recursive func definition, gdc evaluates too often

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

           Summary: With recursive func definition, gdc evaluates too often
           Product: DGCC aka GDC
           Version: 0.24
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: glue layer
        AssignedTo: dvdfrdmn users.sf.net
        ReportedBy: default_357-line yahoo.de


Take the following program:

import std.stdio, std.bind;
template SR(T...) { typedef SR!(T) delegate(T) SR; }
SR!(int) whee(int foo, int depth=1) {
  writefln(depth, ", foo is ", foo);
  return cast(SR!(int))bind(&whee, _0, depth+1).ptr;
}

void main() {
  whee(23)(42)(69);
}

What would be expected here is the following output:
1, foo is 23
2, foo is 42
3, foo is 69
What I get, however, is
1, foo is 23
1, foo is 23
2, foo is 42
1, foo is 23
1, foo is 23
2, foo is 42
3, foo is 69

It seems as if GDC evaluates the first function (1), then evaluates it again to
get the second function (1 2), then does the whole thing again to get the third
function. This, of course, slightly breaks the code. :)
 --downs


-- 
Sep 11 2007
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1492


dvdfrdmn users.sf.net changed:

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





Fixed in svn rev 159 / release 0.25


-- 
Sep 13 2007