www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - mixin identifier and operator syntax

reply "Bent Rasmussen" <exo bent-rasmussen.info> writes:
This crashes on DMD 0.95 XP SP1. The issue is the use of [] syntax to invoke
opIndex.

module test;

template Test()
{
    bit opIndex(bit x)
    {
        return !x;
    }
}

void main()
{
    mixin Test!() xs;
    bit x = xs[false];
}

I'm not sure if it is allowed, but I don't see why not.
Jul 17 2004
parent "Walter" <newshound digitalmars.com> writes:
It shouldn't be allowed, since operator overloading is for structs and
classes.

"Bent Rasmussen" <exo bent-rasmussen.info> wrote in message
news:cdcrm9$1u85$1 digitaldaemon.com...
 This crashes on DMD 0.95 XP SP1. The issue is the use of [] syntax to
invoke
 opIndex.

 module test;

 template Test()
 {
     bit opIndex(bit x)
     {
         return !x;
     }
 }

 void main()
 {
     mixin Test!() xs;
     bit x = xs[false];
 }

 I'm not sure if it is allowed, but I don't see why not.
Jul 20 2004