From: Vincent Pit Date: Fri, 2 Jan 2009 11:01:50 +0000 (+0100) Subject: Fix overload index mismatch in overloading logic. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d87d3eede5d67a7d281a1d929949e466e06bc21a;p=p5sagit%2Fp5-mst-13.2.git Fix overload index mismatch in overloading logic. In amagic_call(), the 'method' arg comes the overload enum in overload.h, but is expected to match the bit set from %overloading::numbers::names. It values wrongly start at 1, differing by 1 from the enum indexes. This didn't appear in the tests because 'method' was reduced modulo 7 instead of 8. --- diff --git a/gv.c b/gv.c index d145579..5b297e4 100644 --- a/gv.c +++ b/gv.c @@ -1865,7 +1865,7 @@ Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags) * masked by overloading.pm */ STRLEN len; const int offset = method / 8; - const int bit = method % 7; + const int bit = method % 8; char *pv = SvPV(lex_mask, len); /* Bit set, so this overloading operator is disabled */ diff --git a/lib/overload/numbers.pm b/lib/overload/numbers.pm index b768758..2e9e9ac 100644 --- a/lib/overload/numbers.pm +++ b/lib/overload/numbers.pm @@ -153,7 +153,7 @@ our @enums = qw# DESTROY #; -{ my $i; our %names = map { $_ => ++$i } @names } +{ my $i = 0; our %names = map { $_ => $i++ } @names } -{ my $i; our %enums = map { $_ => ++$i } @enums } +{ my $i = 0; our %enums = map { $_ => $i++ } @enums } diff --git a/overload.pl b/overload.pl index 01dd550..6f0fe34 100644 --- a/overload.pl +++ b/overload.pl @@ -58,9 +58,9 @@ our \@enums = qw# @enums #; -{ my \$i; our %names = map { \$_ => ++\$i } \@names } +{ my \$i = 0; our %names = map { \$_ => \$i++ } \@names } -{ my \$i; our %enums = map { \$_ => ++\$i } \@enums } +{ my \$i = 0; our %enums = map { \$_ => \$i++ } \@enums } EOF }