Bug 1588 – std variant changes type at opMul

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2007-10-16T17:55:00Z
Last change time
2015-06-09T01:14:19Z
Assigned to
andrei
Creator
frank

Comments

Comment #0 by frank — 2007-10-16T17:55:43Z
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));