[Issue 1864] New: Variable incorrectly declared final in final class template

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Feb 24 01:09:22 PST 2008


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

           Summary: Variable incorrectly declared final in final class
                    template
           Product: D
           Version: 1.027
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: samukha at voliacable.com


Fails to compile with: Error: cannot modify final variable 'baz'.

----
final class Foo()
{
    void bar()
    {
        int baz;
        baz = 1;
    }
}

void main()
{
    auto foo = new Foo!();
}
----

The workaround is to define the template in full:

----
template Foo()
{
    final class Foo
    {
        void bar()
        {
            int baz;
            baz = 1;
        }                
    }
}
----


-- 



More information about the Digitalmars-d-bugs mailing list