Bug 21405 – ctRegex doesn't work in compile time

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-11-19T04:07:44Z
Last change time
2021-08-22T16:30:54Z
Assigned to
No Owner
Creator
Nikolay Belov

Comments

Comment #0 by nocomentsspb — 2020-11-19T04:07:44Z
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 ***