www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - strange Variant bug...

reply "Lloyd Dupont" <ld-REMOVE galador.net> writes:
I have DMD2.053 on Windows 7 x64
The following program compiled and crash on the line where I compare v7 and 
v1
=====================
module main;

import std.variant;
import std.stdio;

class Foo
{
}

int main(string[] argv)
{
    Variant v1 = Variant.init;
    Object o = new Foo();
    Variant v7 = Variant(o);

    writeln(v7 == v1);

    return 0;
}
=====================

What's going on? and any work around?
I do need to use untyped / Object Variant! 
Jun 21 2011
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 6/21/11 9:05 AM, Lloyd Dupont wrote:
 I have DMD2.053 on Windows 7 x64
 The following program compiled and crash on the line where I compare v7
 and v1
 =====================
 module main;

 import std.variant;
 import std.stdio;

 class Foo
 {
 }

 int main(string[] argv)
 {
 Variant v1 = Variant.init;
 Object o = new Foo();
 Variant v7 = Variant(o);

 writeln(v7 == v1);

 return 0;
 }
 =====================

 What's going on? and any work around?
 I do need to use untyped / Object Variant!
Sorry. Fixed in https://github.com/D-Programming-Language/phobos/commit/ee5c3a39e55bc39d49fc4 aed9b2c81cccdb4122. This gave me the opportunity to also fix a not-yet-released bug that would have been embarrassing - bool true and false would have been printed as characters 1 and 0. Feel free to patch your installation. A workaround is to reverse the order of comparisons if you know the right-hand side is always initialized. Andrei
Jun 21 2011
parent reply "Lloyd Dupont" <ld-REMOVE galador.net> writes:
Hi Andrei,

Thanks for the quick fix and work around! :)

Mm.. unfortunately Variant.init can be on either side of the equality, 
depending on the circumstances...
I'll have to learn how to get the latest D compiler from the sources.. :~
Is there a wiki HowTo somewhere?

"Andrei Alexandrescu"  wrote in message 
news:itqb62$2e8i$1 digitalmars.com...

On 6/21/11 9:05 AM, Lloyd Dupont wrote:
 I have DMD2.053 on Windows 7 x64
 The following program compiled and crash on the line where I compare v7
 and v1
 =====================
 module main;

 import std.variant;
 import std.stdio;

 class Foo
 {
 }

 int main(string[] argv)
 {
 Variant v1 = Variant.init;
 Object o = new Foo();
 Variant v7 = Variant(o);

 writeln(v7 == v1);

 return 0;
 }
 =====================

 What's going on? and any work around?
 I do need to use untyped / Object Variant!
Sorry. Fixed in https://github.com/D-Programming-Language/phobos/commit/ee5c3a39e55bc39d49fc46aed9b2c81cccdb4122. This gave me the opportunity to also fix a not-yet-released bug that would have been embarrassing - bool true and false would have been printed as characters 1 and 0. Feel free to patch your installation. A workaround is to reverse the order of comparisons if you know the right-hand side is always initialized. Andrei
Jun 22 2011
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 6/22/11 5:02 AM, Lloyd Dupont wrote:
 Hi Andrei,

 Thanks for the quick fix and work around! :)

 Mm.. unfortunately Variant.init can be on either side of the equality,
 depending on the circumstances...
 I'll have to learn how to get the latest D compiler from the sources.. :~
 Is there a wiki HowTo somewhere?
Not yet. But as a simple recourse I was simply suggesting you do surgery on your installation. Pop your editor, open /your/install/path/variant.d and insert that code. No need to change stdio.d, just variant.d. The next release will contain the fix anyway. Good luck, Andrei
Jun 22 2011
parent "Lloyd Dupont" <ld-REMOVE galador.net> writes:
Sorry for the late answer I was sick, and thanks for the fix!
It works indeed! :)

Now... on onto other bugs! :)


"Andrei Alexandrescu"  wrote in message 
news:itst81$1qbe$2 digitalmars.com...

On 6/22/11 5:02 AM, Lloyd Dupont wrote:
 Hi Andrei,

 Thanks for the quick fix and work around! :)

 Mm.. unfortunately Variant.init can be on either side of the equality,
 depending on the circumstances...
 I'll have to learn how to get the latest D compiler from the sources.. :~
 Is there a wiki HowTo somewhere?
Not yet. But as a simple recourse I was simply suggesting you do surgery on your installation. Pop your editor, open /your/install/path/variant.d and insert that code. No need to change stdio.d, just variant.d. The next release will contain the fix anyway. Good luck, Andrei
Jun 24 2011