D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 8689 - Variant opArithmetic does not attempt float conversion
Summary: Variant opArithmetic does not attempt float conversion
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-18 13:27 UTC by callumenator
Modified: 2013-01-02 00:28 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description callumenator 2012-09-18 13:27:20 UTC
Variant tries to mimic D's built-in rules for arithmetic 
conversions but:

import std.variant, std.stdio;
void main()
{
  auto v1 = Variant(4.5f);
  auto v2 = Variant(3.5f);
  writeln((v1+v2).type()); // double (should be float)
}

The reason is Variant doesn't try to convert to float in 
opArithmetic. I have submitted a pull request fixing this.
Comment 1 github-bugzilla 2012-09-28 06:40:48 UTC
Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/d94803416b683e4aa693c92133c258e8cfc730d6
Merge pull request #805 from callumenator/master

Fix for issue 8689, Variant doesn't attempt float conversion in opArithmetic
Comment 2 yebblies 2013-01-02 00:28:32 UTC
Seems to be fixed in 2.061