[Issue 5406] New: [patch] Major regressions in std.algorithm for functions relying on is(typeof(binaryFun!... due to a static assert in binaryFunImpl
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jan 3 21:20:35 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5406
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
AssignedTo: nobody at puremagic.com
ReportedBy: sandford at jhu.edu
--- Comment #0 from Rob Jacques <sandford at jhu.edu> 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~");}()";
typeof(mixin(testAsExpression))
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: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list