Thread overview
[Issue 1588] New: std variant changes type at opMul
Oct 16, 2007
d-bugmail
Oct 17, 2007
d-bugmail
Mar 07, 2008
d-bugmail
October 16, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1588

           Summary: std variant changes type at opMul
           Product: D
           Version: 2.006
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: frank@frankhirsch.net


I declare and initialse two Variants:

  Variant va=1;
  Variant vb=-2;

This works as expected:

  printf("%i\n",va.get!(int));
  printf("%i\n",vb.get!(int));

Here be dragons at runtime:

  printf("%i\n",(va+vb).get!(int));
  -> Error: Variant: attempting to use incompatible types ulong and int

  printf("%i\n",(va*vb).get!(int));
  -> Error: Variant: attempting to use incompatible types ulong and int

Why the heck "ulong"? Makes no sense to me...

printf("%ul\n",(va+vb).get!(ulong)); // of course this is nonsense for -1
printf("%ul\n",(va*vb).get!(ulong)); // of course this is nonsense for -2

This, erm, "works", but I wouldn't...

printf("%i\n",(va+vb).get!(ulong));
printf("%i\n",(va*vb).get!(ulong));


-- 

October 17, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1588


andrei@metalanguage.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED




-- 

March 07, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1588


andrei@metalanguage.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED




--