Thread overview
Compiler bug?
Aug 16, 2017
apz28
Aug 16, 2017
Daniel Kozak
Aug 16, 2017
Daniel Kozak
August 16, 2017
abstract class A
{
	string _s;
	
@property:
	final string s()
	{
		return _s;
	}
	
	A s(string x)
	{
		_s = x;
		return this;
	}
}

class B : A
{
@property:
	final override A s(string x)
	{
		_s = x;
		return this;
	}
}
	
void main()
{
	B b = new B();
	b.s = "abc";
	assert(b.s == "abc");
}

Compilation output
/d536/f408.d(32): Error: function f408.B.s (string x) is not callable using argument types ()
August 16, 2017
No it is not a bug, there is no s() in B, you can fix this by adding:

alias s = A.s;

to class B

On Wed, Aug 16, 2017 at 7:21 AM, apz28 via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote:

> abstract class A
> {
>         string _s;
>
> @property:
>         final string s()
>         {
>                 return _s;
>         }
>
>         A s(string x)
>         {
>                 _s = x;
>                 return this;
>         }
> }
>
> class B : A
> {
> @property:
>         final override A s(string x)
>         {
>                 _s = x;
>                 return this;
>         }
> }
>
> void main()
> {
>         B b = new B();
>         b.s = "abc";
>         assert(b.s == "abc");
> }
>
> Compilation output
> /d536/f408.d(32): Error: function f408.B.s (string x) is not callable
> using argument types ()
>


August 16, 2017
and some doc: http://dlang.org/spec/function.html#function-inheritance

On Wed, Aug 16, 2017 at 7:45 AM, Daniel Kozak <kozzi11@gmail.com> wrote:

> No it is not a bug, there is no s() in B, you can fix this by adding:
>
> alias s = A.s;
>
> to class B
>
> On Wed, Aug 16, 2017 at 7:21 AM, apz28 via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote:
>
>> abstract class A
>> {
>>         string _s;
>>
>> @property:
>>         final string s()
>>         {
>>                 return _s;
>>         }
>>
>>         A s(string x)
>>         {
>>                 _s = x;
>>                 return this;
>>         }
>> }
>>
>> class B : A
>> {
>> @property:
>>         final override A s(string x)
>>         {
>>                 _s = x;
>>                 return this;
>>         }
>> }
>>
>> void main()
>> {
>>         B b = new B();
>>         b.s = "abc";
>>         assert(b.s == "abc");
>> }
>>
>> Compilation output
>> /d536/f408.d(32): Error: function f408.B.s (string x) is not callable
>> using argument types ()
>>
>
>