[Issue 12777] const/immutable member function violating its const-ness - confusing error message
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Wed May 21 01:29:57 PDT 2014
    
    
  
https://issues.dlang.org/show_bug.cgi?id=12777
Andrej Mitrovic <andrej.mitrovich at gmail.com> changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich at gmail.com
--- Comment #2 from Andrej Mitrovic <andrej.mitrovich at gmail.com> ---
(In reply to Ivan Kazmenko from comment #0)
> First, member "v" is not constant - the method is.
No, it's not the 'method', it's the 'this' reference which is constant. And
const is transitive in D, which means all fields are constant. The above is
equivalent to:
-----
struct S {
    const(int) v;  // as seen from 'fun'
    void fun () const {v++;}
}
struct S {
    immutable(int) v;  // as seen from 'fun'
    void fun () immutable {v++;}
}
-----
However I do agree the diagnostic could be improved a bit.
--
    
    
More information about the Digitalmars-d-bugs
mailing list