View mode: basic / threaded / horizontal-split · Log in · Help
March 27, 2012
immutable method not callable using argument types () - doesn't make sense
I have: [code]

     module A;
	module A;

	interface B {
	   public:
		  immutable B dup();
	}

	class A : B {
	   public:
		  this() {}
		  this(in char[] field) { this.field = field.dup; }
		  immutable A dup() { return new A(field); }
	   private:
		  char[] field;
	}

	void main()
	{
		B f, g;
		f = new A;
		g = new A;
		
		f = g.dup;
	}
I get
March 27, 2012
Re: immutable method not callable using argument types () - doesn't make sense
Repost please delete
February 07, 2013
Re: immutable method not callable using argument types () - doesn't make sense
2012/3/27 Daniel Donnelly <enjoysmath@gmail.com>

> I have: [code]
>
>      module A;
>         module A;
>
>         interface B {
>            public:
>                   immutable B dup();
>         }
>
>         class A : B {
>            public:
>                   this() {}
>                   this(in char[] field) { this.field = field.dup; }
>                   immutable A dup() { return new A(field); }
>            private:
>                   char[] field;
>         }
>
>         void main()
>         {
>                 B f, g;
>                 f = new A;
>                 g = new A;
>
>                 f = g.dup;
>         }
>

With git head (2.062alpha):

test.d(21): Error: immutable method test.B.dup is not callable using a
mutable object

Kenji Hara
Top | Discussion index | About this forum | D home