On Mon, Jul 15, 2013 at 04:57:43PM +0400, Damian Conway wrote: > package RegexProcessor; > use overload ( > q{""} => sub { > my ($pat) = @_; > return $pat->[0]; > }, > q{.} => sub { > my ($a1, $a2) = @_; > $a1 = $a1->[0] if ref $a1; > $a2 = $a2->[0] if ref $a2; > return bless [ "$a1$a2" ], 'RegexProcessor'; > }, > ); > > package main; > use re 'eval'; > > BEGIN { > overload::constant qr => sub { return bless [ $_[0] ], > 'RegexProcessor' }; > } > > my %hash = ( a => 1, b => 2, c => 3); > > "" =~ m{ (?{say join ', ', keys %hash}) }xms; > Fixed in blead with the following commit; suitable for pack-porting to 5.18.2/ commit c3923c33af542d8764d5a1e4eb5d7b311f443b89 Author: David Mitchell <davem@iabyn.com> AuthorDate: Tue Aug 6 16:34:50 2013 +0100 Commit: David Mitchell <davem@iabyn.com> CommitDate: Tue Aug 6 16:44:12 2013 +0100 reparse compile-time /(?{})/ in right scope When a compile-time regex like /...(?{ code-block }) .../ is compiled in the presence of constant and concat overloading, this can cause (still at compile-time) for the pattern to be evaled and re-compiled, in order to re-compile any code-blocks that got messed up during the overloading and thus whose text no longer matches that which the perl parser previously compiled. When this happens, eval_sv() happens to be called when the perl parser is still in compiling state; normally its called from running state. This tickles an undiscovered bug in Perl_find_runcv_where(), which finds the current cop sequence by looking at PL_curcop->cop_seq. At compile time, we need to get it from PL_cop_seqmax instead. M pp_ctl.c M t/re/overload.t -- In economics, the exam questions are the same every year. They just change the answers.Thread Previous | Thread Next