One shouldn't be able to dereference a GLOB as a SCALAR.
authorYitzchak Scott-Thoennes <sthoenna@efn.org>
Sun, 12 Feb 2006 09:18:39 +0000 (01:18 -0800)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Tue, 14 Feb 2006 13:23:04 +0000 (13:23 +0000)
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

pp.c
t/op/ref.t

diff --git a/pp.c b/pp.c
index 9eaac05..4080c45 100644 (file)
--- 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");
        }
     }
index e629d86..784c34c 100755 (executable)
@@ -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);