www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21405] New: ctRegex doesn't work in compile time


          Issue ID: 21405
           Summary: ctRegex doesn't work in compile time
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: nocomentsspb gmail.com

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:
/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()

Nov 18 2020