#356 overload::Method() does not return coderef for stringification

critical
closed
nobody
None
8
2014-12-31
2014-07-04
Zakariyya Mughal
No

This may be a Perl bug. I'm not sure why it is happening:

use Test::More;
use PDL;
my $pdl = sequence(3,3);
ok( overload::Method($pdl, '""'), 'piddle stringifies');
done_testing;

The test fails because overload::Method() returns undef. This is not the
case with any of the other PDL overloaded operators nor do other objects that
stringify exhibit the same behaviour.

Discussion

  • As discussed in #pdl, the overload for stringification in PDL/Core.pm is listed as

    "\"\""  =>  \&PDL::Core::string   );
    

    PDL::Core::string is just an alias to PDL::string. Changing the overload to

    "\"\""  =>  \&PDL::string   );
    

    fixes the reported bug.

     
  • From p5p: this is the correct way of using overload with aliased subroutines (by putting the aliasing in BEGIN).

     
  • Chris Marshall
    Chris Marshall
    2014-12-20

    • Priority: 5 --> 8
     
  • Chris Marshall
    Chris Marshall
    2014-12-20

    Raising priority as I thought this was already merged in....

     
  • Chris Marshall
    Chris Marshall
    2014-12-31

    • status: open --> closed
     
  • Chris Marshall
    Chris Marshall
    2014-12-31

    Thanks for the fix. Released in CHM/PDL-2.007_05.tar.gz and in the coming PDL-2.008 release this January 2015.