On 06/29/2012 09:17 PM, Jacob Carlborg wrote:
I just noticed that the return type of a function can be inferred
without using a storage class:


@property foo ()
{
     return "foo";
}

void main ()
{
     string str = foo;
}

Is that supposed to work?

Yes.

The specification says:

"If it does not already have a storage class, use the auto storage class."

But @property is not a storage class. It seems I can put most of the
attributes there instead of @property, both those with and without a @.


The spec (and the implementation as well) considers them to be storage
classes. I think the term 'storage class' should be retired.


Second, it seems it's not possible to override a method with an inferred
return type, as the example below shows:

class Foo
{
     auto foo ()
     {
         return "Foo";
     }
}

class Bar : Foo
{
     auto foo ()
     {
         return "Bar";
     }
}

void main ()
{
     Foo f = new Bar;
     writeln(f.foo());
}

Results in:

Error: function main.Bar.foo of type () overrides but is not covariant
with main.Foo.foo of type ()

--
/Jacob Carlborg

This is a bug I have run into as well, but I have missed to report it.

Reply via email to