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: nob...@puremagic.com
        ReportedBy: jmdavisp...@gmx.com


--- Comment #0 from Jonathan M Davis <jmdavisp...@gmx.com> 2012-05-29 02:36:43 
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

or, if pull request #611 (
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: -------

Reply via email to