Bug 6261 – [2.054 beta regression] Regex cannot take a char[]
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-07-06T13:30:00Z
Last change time
2011-07-30T13:39:59Z
Keywords
patch
Assigned to
dmitry.olsh
Creator
Jesse.K.Phillips+D
Comments
Comment #0 by Jesse.K.Phillips+D — 2011-07-06T13:30:08Z
The code below will not compile:
import std.regex;
void main(){
auto re = regex("foo".dup);
}
src\phobos\std\regex.d(1537): Error: cannot cast a
read-only string literal to mutable in CTFE
src\phobos\std\regex.d(1537): Error: cannot evaluate
tuple("","\x01") at compile time
I think there is a bug report on this, but also notice the instantiation line isn't given (only the line in regex.d).
Comment #1 by dmitry.olsh — 2011-07-06T14:40:11Z
Well it's not a bug in DMD. The issue is that CTFE got an upgrade, and detects more subtle bugs it seems.
The main issue is that it no longer works with mutable patterns.
This also fails:
import std.regex;
void main(){
char[] a = new char[256];
auto re = regex(a);
}
So it's a bug in std.regex, at that exact line. (Again: it is an issue of sloppy typecheck)
I'll see about a proper fix.
Comment #2 by Jesse.K.Phillips+D — 2011-07-06T16:05:00Z
I wasn't sure as I didn't really expect any CTFE to be happening.