Perl-Critic / PPI

53 stars 44 forks source link

throw on existing PPI::Exception object does not add callers info unless callers already populated #153

Open moregan opened 9 years ago

moregan commented 9 years ago

If throw is called on the PPI::Exception class name, callers information is populated inside the object:

perl -MData::Dumper -WE 'use PPI::Exception; eval { PPI::Exception->throw() }; say Dumper $@->callers'
$VAR1 = [
          'main',
          '-e',
          1,
          'PPI::Exception::throw',
          1,
          undef,
          undef,
          undef,
          469895168,
          'UUUUUUUUUUUUU',
          {
            'feature_arybase' => 1,
            'feature___SUB__' => 1,
            'feature_fc' => 1,
            'feature_unieval' => 1,
            'feature_unicode' => 1,
            'feature_evalbytes' => 1,
            'feature_say' => 1,
            'feature_state' => 1,
            'feature_switch' => 1
          }
        ];

If throw is called on a PPI::Exception object that already has some callers information, more callers information is populated. However, if throw is called on a PPI::Exception object with no callers information populated yet, callers information is not populated:

perl -MData::Dumper -WE 'use PPI::Exception; eval { PPI::Exception->new()->throw() }; say Dumper $@->callers'

Is this behavior intentional, @adamkennedy ? Rationale?

adamkennedy commented 9 years ago

It's probably not intentional, that I can recall. On Dec 24, 2014 2:29 PM, "moregan" notifications@github.com wrote:

If throw is called on the PPI::Exception class name, callers information is populated inside the object:

perl -MData::Dumper -WE 'use PPI::Exception; eval { PPI::Exception->throw() }; say Dumper $@->callers' $VAR1 = [ 'main', '-e', 1, 'PPI::Exception::throw', 1, undef, undef, undef, 469895168, 'UUUUUUUUUUUUU', { 'feature_arybase' => 1, 'feature_SUB' => 1, 'feature_fc' => 1, 'feature_unieval' => 1, 'feature_unicode' => 1, 'feature_evalbytes' => 1, 'feature_say' => 1, 'feature_state' => 1, 'feature_switch' => 1 } ];

If throw is called on a PPI::Exception object that already has some callers information, more callers information is populated. However, if throw is called on a PPI::Exception object with no callers information populated yet, callers information is not populated:

perl -MData::Dumper -WE 'use PPI::Exception; eval { PPI::Exception->new()->throw() }; say Dumper $@->callers'

Is this behavior intentional, @adamkennedy https://github.com/adamkennedy ? Rationale?

— Reply to this email directly or view it on GitHub https://github.com/adamkennedy/PPI/issues/153.