www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13628] New: Error: immutable method S.~this is not callable

https://issues.dlang.org/show_bug.cgi?id=13628

          Issue ID: 13628
           Summary: Error: immutable method S.~this is not callable using
                    a mutable object and vice versa
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: Marco.Leise gmx.de

I get these errors on structs that define a `~this() immutable`:

    Error: immutable method Lib.Sys.File.File.~this is not callable using a
mutable object
    Error: mutable method Lib.Sys.File.File.~this is not callable using a
immutable object
    Error: mutable method Lib.Sys.FileMapping.FileMapping.~this is not callable
using a immutable object
    Error: mutable method Lib.Sys.File.File.~this is not callable using a
immutable object
    Error: immutable method Lib.Sys.FileMapping.FileMapping.~this is not
callable using a mutable object

For starters it would be nice in which functions these destructions happen.

But then ... WAT?

A) Why would the compiler call the exact opposite dtor of what is needed and
the complain? :)

B) If I did actually try to define both `~this()` and `~this() immutable` the
compiler would complain that I cannot define both.

C) Why can a dtor be immutable if you cannot even define both a mutable and
immutable version to special case some code? It seems to add a lot of
complexity.


It seems to me that immutable still has a way to go or that we need to disallow
certain usages of immutable.

--
Oct 17 2014