[Issue 9162] New: [tdpl] Non-static structs should have access to outer lexical scope

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 15 11:40:32 PST 2012


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

           Summary: [tdpl] Non-static structs should have access to outer
                    lexical scope
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: hsteoh at quickfur.ath.cx


--- Comment #0 from hsteoh at quickfur.ath.cx 2012-12-15 11:40:31 PST ---
The following is adapted from Walter's "Voldemort Types" article:

import std.stdio;

auto makeVoldemort(int x) {
        struct Voldemort {
                @property int value() { return x; }
                // Compile error:
        }
        return Voldemort();
}

void main() {
        auto v = makeVoldemort(123);
        writeln(v.value);
}

Compiler output:
test.d(5): Error: function test.makeVoldemort.Voldemort.value cannot access
frame of function test.makeVoldemort

According to TDPL, §7.1.9 (p.263): <quote>Nested structs embed the magic "frame
pointer" that allows them to access outer values such as a and b in the example
above."</quote>

-- 
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