This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #122498] Odd error message from m/(?(??{}))/
authorFather Chrysostomos <sprout@cpan.org>
Sun, 10 Aug 2014 05:39:43 +0000 (22:39 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 10 Aug 2014 05:41:04 +0000 (22:41 -0700)
commit10380cb3585f27510276b532ec6e5450d1b16391
tree7926363243de9afe626e9e789023f683536405d2
parent672794ca55bc11c78c1244bba9039f731071e1bf
[perl #122498] Odd error message from m/(?(??{}))/

I know this code is invalid, but the error message makes no sense:

$ perl5.14.4 -e 'm/(?(??{}))/'
Sequence (? incomplete in regex; marked by <-- HERE in m/(? <-- HERE (??{}))/ at -e line 1.

Not exactly logical, but close....

$ perl5.18.2 -e 'm/(?(??{}))/'
The regex_sets feature is experimental in regex; marked by <-- HERE in m/(?( <-- HERE ??{}))/ at -e line 1.
Syntax error in (?[...]) in regex m/(?(??{}))/ at -e line 1.

As of 5.18, it makes no sense at all.

It should probably say ‘Unknown switch condition’.

This commit makes it do that.  The problem was unintentional fall-
through to the wrong switch condition.

In fact, it could get quite confused:

$  ./miniperl -Ilib -e  'm/(?(? [a] ])/'
The regex_sets feature is experimental in regex; marked by <-- HERE in m/(?( <-- HERE ? [a] ])/ at -e line 1.
Unexpected character in regex; marked by <-- HERE in m/(?(? <-- HERE  [a] ])/ at -e line 1.

Because it was assuming that the character after the first ? was [
and then trying to parse an extended charclass from the second ques-
tion mark.
regcomp.c
t/re/reg_mesg.t