leonerd / perl5

🐫 The Perl programming language
https://dev.perl.org/perl5/
Other
7 stars 1 forks source link

field visibility detection when parsing can be tricked #20

Open wolfsage opened 2 years ago

wolfsage commented 2 years ago
#!./perl -Ilib

use v5.36;

use Devel::Peek;
use Data::Dumper;

use feature 'class', 'defer';
no warnings 'experimental::class';

use experimental qw(refaliasing);

class what {
  method foo {
    class hah {
      field $x;
      sub oh { $x }
    }
  }
}

Output:

Variable "$x" will not stay shared at ./bad.pl line 17

I expect to see something like:

Field $x is not accessible outside a method at ./hmit line 17.
leonerd commented 2 years ago

Ohgod because the CvOUTSIDE walk doesn't realise it should stop at the first -named- sub. I should fix that.