www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - "is" bug with inout type + voldemort ?

//----
auto S()
{
   static struct Result
   {
     this(int, int){}
     inout(Result) get() inout
     {
         return this;
     }
   }
   return Result(1, 2);
}

void main()
{
   auto a = S();
   auto b = a.get();
   a = b; //Check proper operation
   alias typeof(a) A;
   alias typeof(b) B;
   writeln("Typeof A: ", A.stringof);
   writeln("Typeof B: ", B.stringof);
   assert(is(A == B));
}
//----
Typeof A: Result
Typeof B: Result
core.exception.AssertError main(26): Assertion failure
//----

I'm investigating a problem, where I call a function whose return 
type is "inout(Return)", from a voldemort instance. The problem 
is that, apparently, the static return type of that call, which 
is "Result", fails the "is" test vs "Result"?

Anyways, the problem goes away if I declare Result as global, or 
if I declare get as a normal non-inout function.

I'm 95 % sure this is a bug, but "is" is a tricky function, so 
I'd like confirmation.

Anybody confirm this is a bug? I haven't found it in the issue 
list.

For info, I found this in phobos, inside iota, on the function 
opSlice:

//----
void main()
{
   auto a = iota(1, 2);
   auto b = a[];
   assert(is(typeof(a) == typeof(b)));
}
//----

Bug, right?
Oct 17 2012