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/(?(??{}))/
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.