Bug 14842 – [REG 2.068-b2] approxEqual does not work with integers

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-07-28T08:23:00Z
Last change time
2017-07-19T17:43:39Z
Keywords
pull
Assigned to
nobody
Creator
swamplobo

Comments

Comment #0 by swamplobo — 2015-07-28T08:23:54Z
This works with dmd2.067.1 but with 2.068-b2 I get the errors shown below. Test code: --- void main() { int a = 10; assert(approxEqual(10, a)); } --- Errors: src/phobos/std/math.d(6718): Error: std.math.fabs called with argument types (int) matches both: src/phobos/std/math.d(3415): std.math.fabs(real x) and: /src/phobos/std/math.d(3421): std.math.fabs(float x) /src/phobos/std/math.d(6725): Error: std.math.fabs called with argument types (int) matches both: /src/phobos/std/math.d(3415): std.math.fabs(real x) and: /src/phobos/std/math.d(3421): std.math.fabs(float x) /src/phobos/std/math.d(6726): Error: std.math.fabs called with argument types (int) matches both: /src/phobos/std/math.d(3415): std.math.fabs(real x) and: /src/phobos/std/math.d(3421): std.math.fabs(float x) /src/phobos/std/math.d(6736): Error: template instance std.math.approxEqual!(int, int, double) error instantiating hack.d(13): instantiated from here: approxEqual!(int, int) Failed: ["dmd", "-v", "-o-", "hack.d", "-I."]
Comment #1 by ilyayaroshenko — 2015-07-28T09:58:41Z
This function should be restricted to floating point numbers, thought.
Comment #2 by kozzi11 — 2015-07-28T11:16:07Z
I agree with ilya: we should add deprecation message for non floating points numbers. This would be better than error
Comment #3 by k.hara.pg — 2015-07-29T04:09:10Z
Comment #4 by bugzilla — 2015-07-31T20:57:01Z
approxEqual is intended only for floating point arguments.
Comment #5 by bugzilla — 2015-07-31T21:15:14Z
Comment #6 by code — 2015-08-04T21:59:14Z
Comment #7 by github-bugzilla — 2015-08-04T22:04:48Z
Commits pushed to stable at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/bd8ed8c13cc4a73a182d8923122c17ba4ea5e524 fix Issue 14842 - [REG 2.068-b2] approxEqual does not work with integers - promote any comparision with integers to real https://github.com/D-Programming-Language/phobos/commit/de8896ae753bd491adba276fe6e653945334b580 Merge pull request #3525 from MartinNowak/fix14842 fix Issue 14842 - [REG 2.068-b2] approxEqual does not work with integers
Comment #8 by github-bugzilla — 2015-08-05T00:15:15Z
Comment #9 by github-bugzilla — 2017-07-19T17:43:39Z
Commits pushed to dmd-cxx at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/bd8ed8c13cc4a73a182d8923122c17ba4ea5e524 fix Issue 14842 - [REG 2.068-b2] approxEqual does not work with integers https://github.com/dlang/phobos/commit/de8896ae753bd491adba276fe6e653945334b580 Merge pull request #3525 from MartinNowak/fix14842