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."]
This function should be restricted to floating point numbers, thought.
I agree with ilya: we should add deprecation message for non floating points numbers. This would be better than error
Introduced in: https://github.com/D-Programming-Language/phobos/pull/3012
approxEqual is intended only for floating point arguments.
https://github.com/D-Programming-Language/phobos/pull/3521
https://github.com/D-Programming-Language/phobos/pull/3525
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
Commits pushed to master 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 https://github.com/D-Programming-Language/phobos/commit/de8896ae753bd491adba276fe6e653945334b580 Merge pull request #3525 from MartinNowak/fix14842
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