Summary: [patch] Major regressions in std.algorithm for
                    functions relying on is(typeof(binaryFun!... due to a
                    static assert in binaryFunImpl
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: patch
          Severity: regression
          Priority: P2
         Component: Phobos

--- Comment #0 from Rob Jacques <> 2011-01-03 21:18:21 PST ---
This is a regression between DMD 2.050 and 2.051.
Several routines in std.algorithm rely on template constraints of the form:
is(typeof(binaryFun!... However, since binaryFun triggers a static assert and
stops compilation, there is a logical error here and causes
find("goodbye","bye"), etc to not compile. This might be rooted in a change to
how DMD handles is statements / static asserts, but there is a simple patch to
Phobos that seems to work around this issue by adding a template constraint to
binaryFunImpl in std.functional:

template binaryFunImpl(alias fun, string parm1Name, string parm2Name) {
    static if (is(typeof(fun) : string)) {
        enum testAsExpression = "{ ElementType1 "
            ~parm1Name~"; ElementType2 "
            ~parm2Name~"; return ("~fun~");}()";

        result(ElementType1, ElementType2)(ElementType1 __a, ElementType2 __b)
            if(__traits(compiles, mixin(testAsExpression)))
            mixin("alias __a "~parm1Name~";");
            mixin("alias __b "~parm2Name~";");
            mixin("return (" ~ fun ~ ");");
    } else {
        alias fun result;

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to