www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11741] New: Fields with void initializers cannot be cooked in constructors

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: jakobovrum gmail.com


--- Comment #0 from Jakob Ovrum <jakobovrum 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: -------
Dec 14 2013
parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11741


Jakob Ovrum <jakobovrum gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #1 from Jakob Ovrum <jakobovrum gmail.com> 2013-12-14 11:06:09 PST
---
(In reply to comment #0)
 Example exhibiting the problem:
 ...
Sorry, this is a duplicate of #10643. *** This issue has been marked as a duplicate of issue 10643 *** -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 14 2013