When I try to compile following code:
----------- t.d ------------------
import std.regex;
string test(string s)() {
auto ctr = ctRegex!(`^.*/([^/]+)/?$`);
auto c = matchFirst(s, ctr);
return s;
}
immutable x = test!("test");
void main() {
}
----------------------
I see
$ dmd t.d
/usr/lib/dmd/2.093/import/std/regex/package.d(456): Error: reinterpreting cast from immutable(Regex!char)* to Regex!char* is not supported in CTFE
/usr/lib/dmd/2.093/import/std/regex/package.d(832): called from here: prog.getRe()
/usr/lib/dmd/2.093/import/std/regex/package.d(995): called from here: matchOnce(input, re)
t.d(5): called from here: matchFirst("test", ctr)
t.d(9): called from here: test()
Comment #1 by nocomentsspb — 2020-11-23T06:12:13Z
For dmd from master branch, the following error message I see:
../dlang/dmd/generated/linux/release/64/../../../../../phobos/std/regex/package.d(859): Error: cannot cast __lambda3 to Captures!string delegate() pure @trusted at compile time
../dlang/dmd/generated/linux/release/64/../../../../../phobos/std/regex/package.d(859): called from here: delegate () pure nothrow @nogc @trusted => cast(Captures!string delegate() pure @trusted)matchOnceImp()
../dlang/dmd/generated/linux/release/64/../../../../../phobos/std/regex/package.d(1005): called from here: matchOnce(input, re)
t.d(5): called from here: matchFirst("test", ctr)
t.d(9): called from here: test()
Comment #2 by snarwin+bugzilla — 2021-08-22T16:30:54Z
*** This issue has been marked as a duplicate of issue 12687 ***