Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overloading regexp issue with lexical scope #410

Open
atoomic opened this issue Jul 18, 2017 · 1 comment
Open

Overloading regexp issue with lexical scope #410

atoomic opened this issue Jul 18, 2017 · 1 comment

Comments

@atoomic
Copy link
Collaborator

atoomic commented Jul 18, 2017

extract from re/overload.t

 {

     # if the pattern gets silently re-parsed, ensure that any eval'ed
     # code blocks get the correct lexical scope. The overloading of
     # concat, along with the modification of the text of the code block,
     # ensures that it has to be re-compiled.

     {
     package OL_MOD;
     use overload
         q{""} => sub { my ($pat) = @_; $pat->[0] },
         q{.}  => sub {
                 my ($a1, $a2) = @_;
                 $a1 = $a1->[0] if ref $a1;
                 $a2 = $a2->[0] if ref $a2;
                 my $s = "$a1$a2";
                 $s =~ s/x_var/y_var/;
                 bless [ $s ];
              },
     ;
     }


     BEGIN {
      overload::constant qr => sub { bless [ $_[0] ], 'OL_MOD' };
     }

     $::x_var  = "ABC";
     my $x_var = "abc";

     $::y_var  = "XYZ";
     my $y_var    = "xyz";

     use re 'eval';
     my $a = 'a';
     print qq[ok - 1\n] if "xyz"  =~ m{^(??{ $x_var })$}; # OL_MOD
     print qq[ok - 2\n] if "xyza" =~ m{^(??{ $x_var })$a$}; # OL_MOD runtime"
 }

The runtime test is working but not the first one

HEAD=

@atoomic
Copy link
Collaborator Author

atoomic commented Jul 18, 2017

sorry wrong project, but still an accurate failure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant