www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8158] New: std.algorithm.min fails to compile with user-defined types

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8158

           Summary: std.algorithm.min fails to compile with user-defined
                    types
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: jmdavisProg gmx.com



PDT ---
This code

import std.algorithm;
import std.datetime;
import std.stdio;

void main()
{
    writeln(min(Date(2012, 5, 7), Date(2011, 2, 9)));
    writeln(max(Date(2012, 5, 7), Date(2011, 2, 9)));
}


should print

2011-Feb-09
2012-May-07

Instead, it fails to compile with

/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/traits.d(4289): Error:
incompatible types for ((min()) == (0)): 'Date' and 'int'
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/traits.d(4289): Error: error
evaluating static if expression
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/algorithm.d(5035): Error:
template instance std.traits.mostNegative!(Date) error instantiating
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/algorithm.d(5055): Error:
template instance std.algorithm.MinType!(Date,Date) error instantiating
q.d(7):        instantiated from here: min!(Date,Date,)
q.d(7): Error: template instance std.algorithm.min!(Date,Date,) error
instantiating


https://github.com/D-Programming-Language/phobos/pull/611 ) is pulled in, it
fails to compile with

/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/algorithm.d(5035): Error:
template instance mostNegative!(Date) mostNegative!(Date) does not match
template declaration mostNegative(T) if (isNumeric!(T) || isSomeChar!(T))
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/algorithm.d(5035): Error:
template instance mostNegative!(Date) mostNegative!(Date) does not match
template declaration mostNegative(T) if (isNumeric!(T) || isSomeChar!(T))
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/algorithm.d(5037): Error:
template instance mostNegative!(Date) mostNegative!(Date) does not match
template declaration mostNegative(T) if (isNumeric!(T) || isSomeChar!(T))
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/algorithm.d(5037): Error:
template instance mostNegative!(Date) mostNegative!(Date) does not match
template declaration mostNegative(T) if (isNumeric!(T) || isSomeChar!(T))
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/algorithm.d(5055): Error:
template instance std.algorithm.MinType!(Date,Date) error instantiating
q.d(7):        instantiated from here: min!(Date,Date,)
q.d(7): Error: template instance std.algorithm.min!(Date,Date,) error
instantiating


In either case, the std.algorithm.min is failing to compile. max actually works
if you comment out the call to min, but min is broken.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 29 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8158




PDT ---
https://github.com/D-Programming-Language/phobos/pull/612

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 07 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8158




Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/adb31e7048d1b8e9661be0508b515a0887d98809


https://github.com/D-Programming-Language/phobos/commit/6048cafc58c722957dc21e94eb47f7046a1a5ff7




-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 30 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8158


Jonathan M Davis <jmdavisProg gmx.com> changed:

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


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 30 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8158




Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/6499322e8937dd987d069f7738a2540ac3c6b022


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 01 2012