[Issue 3995] Can't access array/AA from function literal defined inside the array/AA's initializer

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 1 19:07:16 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=3995


yebblies <yebblies at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies at gmail.com
           Platform|Other                       |All
            Version|1.050                       |D1 & D2
             Blocks|340                         |
         OS/Version|Windows                     |All
           Severity|normal                      |enhancement


--- Comment #2 from yebblies <yebblies at gmail.com> 2012-02-02 14:07:15 EST ---
This is working as intended.

Variables are not added to the scope until after their initializers are
processed, preventing garbage like this:

int x = x;

And other cases where this would make it possible to refer to uninitialized
variables that, even when they have an initializer.

A trivial workaround is the following:

int delegate(int)[string] dgMap;
auto tmp = [ ... delegate definitions referring to dgMap ... ];
dgMap = tmp;

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


More information about the Digitalmars-d-bugs mailing list