summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-06-06 23:19:47 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-06-07 08:18:55 -0700
commitb1d0a83378b21d719f9e1fd57b852ca875a7c228 (patch)
tree05a5fbcb06aa56bd3f6618367888e04e95366825
parent288163b0396d677d915ce0beb12619dc26646926 (diff)
downloadperl-b1d0a83378b21d719f9e1fd57b852ca875a7c228.tar.gz
Make warn treat $@=3 and $@="3" the same
If we get this: $ ./perl -Ilib -e '$@ = "3"; warn' 3 ...caught at -e line 1. then we shouldn’t get this: $ ./perl -Ilib -e '$@ = 3; warn' Warning: something's wrong at -e line 1. as the two scalars hold the same value.
-rw-r--r--pp_sys.c2
-rw-r--r--t/op/warn.t8
2 files changed, 8 insertions, 2 deletions
diff --git a/pp_sys.c b/pp_sys.c
index 994bd6ce9c..79ef266c7f 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -453,7 +453,7 @@ PP(pp_warn)
}
else exsv = ERRSV;
}
- else if (SvPOKp(ERRSV) && SvCUR(ERRSV)) {
+ else if (SvPOKp(ERRSV) ? SvCUR(ERRSV) : SvNIOKp(ERRSV)) {
exsv = sv_newmortal();
sv_setsv_nomg(exsv, ERRSV);
sv_catpvs(exsv, "\t...caught");
diff --git a/t/op/warn.t b/t/op/warn.t
index a0a072e247..71de5e2cca 100644
--- a/t/op/warn.t
+++ b/t/op/warn.t
@@ -7,7 +7,7 @@ BEGIN {
require './test.pl';
}
-plan 28;
+plan 30;
my @warnings;
my $wa = []; my $ea = [];
@@ -186,4 +186,10 @@ is @warnings, 1;
object_ok $warnings[0], 'o',
'warn $tie_returning_object_that_stringifes_emptily';
+@warnings = ();
+eval "#line 42 Cholmondeley\n \$\@ = '3'; warn";
+eval "#line 42 Cholmondeley\n \$\@ = 3; warn";
+is @warnings, 2;
+is $warnings[1], $warnings[0], 'warn treats $@=3 and $@="3" the same way';
+
1;