[Issue 6695] typeof(this) does not take into account const/immutable attributes inside member functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Sep 20 10:27:22 PDT 2011


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



--- Comment #6 from Steven Schveighoffer <schveiguy at yahoo.com> 2011-09-20 10:26:54 PDT ---
(In reply to comment #5)
> so this is a bug or not ... ?
> 
> // Error: function b.c () is not callable using argument types () immutable
> 
> import std.stdio;
> 
> immutable struct a {
>   b b1;
> }
> 
> struct b {
>   void c () { }
> }
> 
> void main () {
>   a a1;
>   a1.b1.c();
> }

Not a bug.  Inside the c function, 'this' is mutable, and you are trying to
pass an immutable struct as the 'this' parameter.  Immutable cannot implicitly
cast to mutable, so it fails to compile.

You should read up on the spec documentation about const and immutable, it will
help to understand it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list