Thread overview
Is this a std.regex bug?
Aug 07, 2012
Andrea Fontana
Aug 07, 2012
Dmitry Olshansky
Aug 08, 2012
Andrea Fontana
Aug 08, 2012
Dmitry Olshansky
August 07, 2012
dmd 2.060 64bit ubuntu:

// Doesn't work:
auto r = ctRegex!(r"/api/places/(id|related|search|count)\.(json|xml)", "g");
		
// Works:
auto r = regex(r"/api/places/(id|related|search|count)\.(json|xml)", "g");
		

August 07, 2012
On 07-Aug-12 16:06, Andrea Fontana wrote:
> dmd 2.060 64bit ubuntu:
>
> // Doesn't work:
> auto r = ctRegex!(r"/api/places/(id|related|search|count)\.(json|xml)",
> "g");
>

Could be. It is experimental and is known to have bugs.
What is the exact problem statement?

> // Works:
> auto r = regex(r"/api/places/(id|related|search|count)\.(json|xml)", "g");
>
>


-- 
Dmitry Olshansky
August 08, 2012
import std.regex;
void main() {
    auto r = ctRegex!(r"/a/b/(c|d|e|f)", "g");
}

This simple app fails at compile time.

Online compiler says:

/usr/local/include/dmd2/std/regex.d(1150): Error:
assert(this.ir[cast(ulong)orStart].code() == cast(IR)129u) failed
/usr/local/include/dmd2/std/regex.d(876):        called from here:
this.parseRegex()
/usr/local/include/dmd2/std/regex.d(6428):        called from here:
parser.this(pattern,flags)
/usr/local/include/dmd2/std/regex.d(6412):        called from here:
regexImpl(pattern,flags)
/usr/local/include/dmd2/std/regex.d(6437):        called from here:
regex("/a/b/(c|d|e|f)","g")
/usr/local/include/dmd2/std/regex.d(1150): Error:
assert(this.ir[cast(ulong)orStart].code() == cast(IR)129u) failed
/usr/local/include/dmd2/std/regex.d(876):        called from here:
this.parseRegex()
/usr/local/include/dmd2/std/regex.d(6428):        called from here:
parser.this(pattern,flags)
/usr/local/include/dmd2/std/regex.d(6412):        called from here:
regexImpl(pattern,flags)
/usr/local/include/dmd2/std/regex.d(6439):        called from here:
regex("/a/b/(c|d|e|f)","g")
/usr/local/include/dmd2/std/regex.d(6439):        called from here:
ctGenRegExCode(regex("/a/b/(c|d|e|f)","g"))
/usr/local/include/dmd2/std/regex.d(1150): Error:
assert(this.ir[cast(ulong)orStart].code() == cast(IR)129u) failed
/usr/local/include/dmd2/std/regex.d(876):        called from here:
this.parseRegex()
/usr/local/include/dmd2/std/regex.d(6428):        called from here:
parser.this(pattern,flags)
/usr/local/include/dmd2/std/regex.d(6412):        called from here:
regexImpl(pattern,flags)
/usr/local/include/dmd2/std/regex.d(6446):        called from here:
regex("/a/b/(c|d|e|f)","g")
/usr/local/include/dmd2/std/regex.d(6446):        called from here:
StaticRegex(null,Regex(null,null,null,0u,0u,0u,0u,0u,null,null,ShiftOr(null,0u,0u))).this(regex("/a/b/(c|d|e|f)","g"),& func)
/usr/local/include/dmd2/std/regex.d(6463): Error: template instance
std.regex.ctRegexImpl!("/a/b/(c|d|e|f)","g") error instantiating
822.d(5):        instantiated from here: ctRegex!("/a/b/(c|d|e|f)","g")
822.d(5): Error: template instance std.regex.ctRegex!("/a/b/(c|d|e|
f)","g") error instantiating



Il giorno mar, 07/08/2012 alle 19.53 +0400, Dmitry Olshansky ha scritto:

> On 07-Aug-12 16:06, Andrea Fontana wrote:
> > dmd 2.060 64bit ubuntu:
> >
> > // Doesn't work:
> > auto r = ctRegex!(r"/api/places/(id|related|search|count)\.(json|xml)",
> > "g");
> >
> 
> Could be. It is experimental and is known to have bugs. What is the exact problem statement?
> 
> > // Works:
> > auto r = regex(r"/api/places/(id|related|search|count)\.(json|xml)", "g");
> >
> >
> 
> 




August 08, 2012
On 08-Aug-12 11:28, Andrea Fontana wrote:
>
> import std.regex;
> void main() {
>      auto r = ctRegex!(r"/a/b/(c|d|e|f)", "g");
> }
>
> This simple app fails at compile time.
( it's not that simple ;) )

But it's "been there, seen that". In short:

> assert(this.ir[cast(ulong)orStart].code() == cast(IR)129u) failed

> assert(this.ir[cast(ulong)orStart].code() == cast(IR)129u) failed

A well known problem search Bugzilla with cast(IR)129u and you'd find it. Or just ctRegex.

And that's something I need to ping Don about. CTFE is still not 1:1 with normal D.

>
> Il giorno mar, 07/08/2012 alle 19.53 +0400, Dmitry Olshansky ha scritto:
>> On 07-Aug-12 16:06, Andrea Fontana wrote:
>> > dmd 2.060 64bit ubuntu:
>> >
>> > // Doesn't work:
>> > auto r = ctRegex!(r"/api/places/(id|related|search|count)\.(json|xml)",
>> > "g");
>> >
>>
>> Could be. It is experimental and is known to have bugs.
>> What is the exact problem statement?
>>
>> > // Works:
>> > auto r = regex(r"/api/places/(id|related|search|count)\.(json|xml)", "g");
>> >
>> >
>>
>>
>


-- 
Dmitry Olshansky