[Issue 12285] New: Allow local symbols in alias parameter to non-static templates when both have same scope

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 2 07:02:59 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12285

           Summary: Allow local symbols in alias parameter to non-static
                    templates when both have same scope
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: thecybershadow at gmail.com
            Blocks: 12230


--- Comment #0 from Vladimir Panteleev <thecybershadow at gmail.com> 2014-03-02 17:02:53 EET ---
///////// test.d ////////
struct S
{
    int a, c;

    template toA(alias s)
    {
        void copy()
        {
            a = s;
        }
    }

    alias cToA = toA!c;
}

unittest
{
    S s;
    s.c = 42;
    s.cToA.copy();
    assert(s.a == 42);
}
/////////////////////////

Currently, this produces:

test.d(13): Error: template instance toA!(c) cannot use local 'c' as parameter
to non-global template toA(alias s)

Note that this restriction only applies to variables, but not methods, because
of issue 12230. Fixing 12230 without merging this would surely break code (e.g.
is std.regex, see set!setInvMask).

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


More information about the Digitalmars-d-bugs mailing list