Weird template error

Jarrett Billingsley jarrett.billingsley at gmail.com
Tue Nov 18 22:15:27 PST 2008


On Wed, Nov 19, 2008 at 12:14 AM, Brian <digitalmars at brianguertin.com> wrote:
> I get this (minor) error using dmd 1.036, I don't know if it's been
> discovered or not.
>
> test.d(20): Error: template foo!(int) is not a member of actor.world
> test.d(20): Error: function expected before (), not 0 of type int
>
> // And heres the code that causes it
> class World {
>        public void foo(T)() {
>        }
>
> }
> class Actor {
>        World _world;
>
>        public World world() {
>                return this._world;
>        }
> }
>
> void main() {
>        auto actor = new Actor;
>        actor._world = new World;
>
>        actor.world().foo!(int)(); // This works fine
>        actor.world.foo!(int)(); // This causes the error
> }

This is just another example of the property sugar being subpar.  With
real properties, this would not happen.  However, as it is,
"actor.world.foo!(int)()" parses as an attempt to access "foo!(int)()"
from the _method_ designated by "actor.world", _not_ from the return
value of actor.world().



More information about the Digitalmars-d mailing list