[Issue 11741] New: Fields with void initializers cannot be cooked in constructors

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 14 10:58:19 PST 2013


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

           Summary: Fields with void initializers cannot be cooked in
                    constructors
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: jakobovrum at gmail.com


--- Comment #0 from Jakob Ovrum <jakobovrum at gmail.com> 2013-12-14 10:58:15 PST ---
Example exhibiting the problem:

---
class S
{
    immutable int a = void;

    this()
    {
        a = 42;
    }
}

---

Error output:

---
test.d(7): Error: cannot modify immutable expression a
---

It compiles and works as expected without the void initializer. It's
understandable behaviour for non-void initializers, but I think the void
initializer should be treated as a special case; fields with void initializers
should be considered uncooked in the constructor.

The example might seem frivolous, but it's important when the field is a
fixed-length array, for which void initializers can make a big difference.

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