www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - immutable method not callable using argument types () - doesn't make

reply "Daniel Donnelly" <enjoysmath gmail.com> writes:
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
Mar 27 2012
next sibling parent "Dan " <enjoysmath gmail.com> writes:
Repost please delete
Mar 27 2012
prev sibling parent kenji hara <k.hara.pg gmail.com> writes:
--047d7bf10a8680f20304d51760f3
Content-Type: text/plain; charset=UTF-8

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 --047d7bf10a8680f20304d51760f3 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: base64 PGRpdiBkaXI9Imx0ciI+PGRpdiBjbGFzcz0iZ21haWxfZXh0cmEiPjxkaXYgY2xhc3M9ImdtYWls X3F1b3RlIj4yMDEyLzMvMjcgRGFuaWVsIERvbm5lbGx5IDxzcGFuIGRpcj0ibHRyIj4mbHQ7PGEg aHJlZj0ibWFpbHRvOmVuam95c21hdGhAZ21haWwuY29tIiB0YXJnZXQ9Il9ibGFuayI+ZW5qb3lz bWF0aEBnbWFpbC5jb208L2E+Jmd0Ozwvc3Bhbj48YnI+PGJsb2NrcXVvdGUgY2xhc3M9ImdtYWls X3F1b3RlIiBzdHlsZT0ibWFyZ2luLXRvcDowcHg7bWFyZ2luLXJpZ2h0OjBweDttYXJnaW4tYm90 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