Bug 8529 – ctRegex - named submatch - hash-table exception
Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-08-09T09:40:00Z
Last change time
2013-03-10T01:08:30Z
Assigned to
dmitry.olsh
Creator
wyrlon
Comments
Comment #0 by wyrlon — 2012-08-09T09:40:46Z
Reported on v2.060 (but no version seems to work).
The code is based on the opIndex example from:
http://dlang.org/phobos/std_regex.html#regex
The normal regex version is functional, but when converting to ctRegex, the hashtable lookup throws.(
auto m = match("a = 42;",
ctRegex!(`(?P<var>\S+)\s*=\s*(?P<value>\d+);`));
auto c = m.captures;
// c["var"]; =>
[email protected](2145): Range violation
// c["value"]; =>
Object.Exception@C:\D\dmd2\windows\bin\..\..\src\phobos\std\regex.d(2145):
no submatch named value
Comment #1 by monarchdodra — 2013-02-25T07:22:34Z
(In reply to comment #0)
> Reported on v2.060 (but no version seems to work).
>
> The code is based on the opIndex example from:
> http://dlang.org/phobos/std_regex.html#regex
>
> The normal regex version is functional, but when converting to ctRegex, the
> hashtable lookup throws.(
>
> auto m = match("a = 42;",
> ctRegex!(`(?P<var>\S+)\s*=\s*(?P<value>\d+);`));
> auto c = m.captures;
>
> // c["var"]; =>
> [email protected](2145): Range violation
>
> // c["value"]; =>
> Object.Exception@C:\D\dmd2\windows\bin\..\..\src\phobos\std\regex.d(2145):
> no submatch named value
Just spent an hour duplicating this one.
Bump.
Since ctRegex is an "Experimental feature.", it may be worth documenting the existence of this bug in http://dlang.org/phobos/std_regex.html#.StaticRegex.
If we don't know how to fix this, it may also be worth temporarily and statically turning down named captures in static regexes, with a "sorry" message.
Comment #2 by monarchdodra — 2013-02-25T07:31:42Z
Bump for Dmitry.
Comment #3 by dmitry.olsh — 2013-03-10T00:56:11Z
Issue 9280 shows it's a general problem in CTFE version of regex parser
*** This issue has been marked as a duplicate of issue 9280 ***
Comment #4 by dmitry.olsh — 2013-03-10T01:08:30Z
(In reply to comment #1)
> (In reply to comment #0)
> > Reported on v2.060 (but no version seems to work).
> >
> > The code is based on the opIndex example from:
> > http://dlang.org/phobos/std_regex.html#regex
> >
> > The normal regex version is functional, but when converting to ctRegex, the
> > hashtable lookup throws.(
> >
Turns out it's not hashtable but rather binary search on a broken array :(
The good news is that the fix turns out to be trivial.