Bug 8380 – -unittest makes it so that std.replace doesn't work on enums
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-07-12T01:42:00Z
Last change time
2015-06-09T05:15:20Z
Assigned to
nobody
Creator
issues.dlang
Comments
Comment #0 by issues.dlang — 2012-07-12T01:42:55Z
This code compiles just fine normally:
import std.array;
import std.stdio;
void main()
{
enum str = q{writeln("hellojoeworld");};
mixin(replace(str, "joe", " "));
}
but if you compile with -unittest, you get this error
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/array.d(1453): Error: template std.array.replace(E,R1,R2) if (isDynamicArray!(E[]) && isForwardRange!(R1) && isForwardRange!(R2) && (hasLength!(R2) || isSomeString!(R2))) forward reference to template replace(E,R1,R2) if (isDynamicArray!(E[]) && isForwardRange!(R1) && isForwardRange!(R2) && (hasLength!(R2) || isSomeString!(R2)))
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/array.d(1453): Error: template std.array.replace(E,R1,R2) if (isDynamicArray!(E[]) && isForwardRange!(R1) && isForwardRange!(R2) && (hasLength!(R2) || isSomeString!(R2))) cannot deduce template function from argument types !()(string,string,string)
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/algorithm.d(414): Error: inout on return means inout must be on a parameter as well for inout(uint)()
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/algorithm.d(479): Error: template instance std.algorithm.DummyRange!(cast(ReturnBy)0,cast(Length)0,cast(RangeType)2) error instantiating
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/algorithm.d(414): Error: inout on return means inout must be on a parameter as well for inout(uint)()
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/algorithm.d(480): Error: template instance std.algorithm.DummyRange!(cast(ReturnBy)0,cast(Length)0,cast(RangeType)3) error instantiating
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/algorithm.d(414): Error: inout on return means inout must be on a parameter as well for inout(uint)()
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/algorithm.d(482): Error: template instance std.algorithm.DummyRange!(cast(ReturnBy)0,cast(Length)1,cast(RangeType)2) error instantiating
This is particularly annoying, because it makes it impossible to use replace on strings at compile time to strip out newlines before mixing them in (to avoid screwing up the line numbers).
Comment #1 by issues.dlang — 2012-07-12T01:47:38Z
Scratch this. Apparently some local changes I had caused this.