From: Vincent Pit Date: Wed, 24 Aug 2011 15:48:45 +0000 (+0200) Subject: The last argument to hv_fetch is the lvalue flag, not the hash X-Git-Tag: v0.12~5 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FLexical-Types.git;a=commitdiff_plain;h=26192e1043cbd952cc7acaa033cc473ffd074085 The last argument to hv_fetch is the lvalue flag, not the hash This could have caused entry vivifications in %^H on 5.8. --- diff --git a/MANIFEST b/MANIFEST index 9d43dcd..1a363a3 100644 --- a/MANIFEST +++ b/MANIFEST @@ -17,6 +17,7 @@ t/14-ro.t t/15-constants.t t/16-scope.t t/17-peep.t +t/18-hints.t t/20-object.t t/21-tie.t t/22-magic.t diff --git a/Types.xs b/Types.xs index 1e76369..bcd5908 100644 --- a/Types.xs +++ b/Types.xs @@ -354,7 +354,7 @@ STATIC SV *lt_hint(pTHX) { 0, lt_hash); #else - SV **val = hv_fetch(GvHV(PL_hintgv), __PACKAGE__, __PACKAGE_LEN__, lt_hash); + SV **val = hv_fetch(GvHV(PL_hintgv), __PACKAGE__, __PACKAGE_LEN__, 0); if (!val) return 0; hint = *val; diff --git a/t/18-hints.t b/t/18-hints.t new file mode 100644 index 0000000..2b0886c --- /dev/null +++ b/t/18-hints.t @@ -0,0 +1,33 @@ +#!perl -T + +use strict; +use warnings; + +use Test::More tests => 2; + +{ + local %^H = (a => 1); + + require Lexical::Types; + + my $err = do { + local $@; + eval <<' VIVIFICATION_TEST'; + package Lexical::Types::TestVivification; + sub TYPEDSCALAR { } + my Lexical::Types::TestVivification $lexical; + VIVIFICATION_TEST + $@; + }; + + # Force %^H repopulation with an Unicode match + my $x = "foo"; + utf8::upgrade($x); + $x =~ /foo/i; + + my $hints = join ',', + map { $_, defined $^H{$_} ? $^H{$_} : '(undef)' } + sort keys(%^H); + is $err, '', 'vivification test code did not croak'; + is $hints, 'a,1', 'Lexical::Types does not vivify entries in %^H'; +}