From: Yitzchak Scott-Thoennes Date: Sun, 12 Feb 2006 09:18:39 +0000 (-0800) Subject: One shouldn't be able to dereference a GLOB as a SCALAR. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cbae9b9ff8bcf8bd286fe05ec47b85b49a5edee5;p=p5sagit%2Fp5-mst-13.2.git One shouldn't be able to dereference a GLOB as a SCALAR. Subject: Re: [perl #38484] Data::Dumper only warns on unhandled reference types Message-ID: <20060212171839.GA3604@efn.org> plus regression tests. p4raw-id: //depot/perl@27179 --- diff --git a/pp.c b/pp.c index 9eaac05..4080c45 100644 --- a/pp.c +++ b/pp.c @@ -234,6 +234,8 @@ PP(pp_rv2sv) case SVt_PVAV: case SVt_PVHV: case SVt_PVCV: + case SVt_PVFM: + case SVt_PVIO: DIE(aTHX_ "Not a SCALAR reference"); } } diff --git a/t/op/ref.t b/t/op/ref.t index e629d86..784c34c 100755 --- a/t/op/ref.t +++ b/t/op/ref.t @@ -8,7 +8,7 @@ BEGIN { require 'test.pl'; use strict qw(refs subs); -plan (98); +plan(102); # Test glob operations. @@ -446,6 +446,18 @@ is ( (sub {"bar"})[0]->(), "bar", 'code deref from list slice w/ ->' ); "deref of undef from list slice fails" ); } +# test dereferencing errors +{ + eval q/ ${*STDOUT{IO}} /; + like($@, qr/Not a SCALAR reference/); + eval q/ @{*STDOUT{IO}} /; + like($@, qr/Not an ARRAY reference/); + eval q/ %{*STDOUT{IO}} /; + like($@, qr/Not a HASH reference/); + eval q/ &{*STDOUT{IO}} /; + like($@, qr/Not a CODE reference/); +} + # Bit of a hack to make test.pl happy. There are 3 more tests after it leaves. $test = curr_test(); curr_test($test + 3);