Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Package-Stash-XS CPAN distribution.

Report information
The Basics
Id: 80497
Status: resolved
Priority: 0/
Queue: Package-Stash-XS

People
Owner: Nobody in particular
Requestors: fitz.elliott [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.25
Fixed in: (no value)



Subject: spurious warning with get_or_add_symbol in BEGIN
Hello! When you use ->get_or_add_symbol() inside a BEGIN block, Package::Stash::XS emits a warning like: Name "Foo::bar" used only once: possible typo at test2.pl line 10. Running the same script with the PP backend or outside the BEGIN block makes the warning go away. I've attached a test script (test2.pl) that demonstrates this. I'm afraid I don't know what the fix would be, but I've attached a patch for t/compile-time.t and t/lib/CompileTime.pm that adds a Test::NoWarnings test for this. Thank you for your time and effort in maintaining this package! Cheers, Fitz Elliott
Subject: test2.pl
#!/usr/bin/env perl use strict; use warnings; BEGIN { use Package::Stash; my $stash = Package::Stash->new('Foo'); $stash->get_or_add_symbol('$bar'); }
Subject: 0001-add-test-for-compile-time-warnings.patch
From b7e046f6adb3b43cb4297e13a7b7f68918d88011 Mon Sep 17 00:00:00 2001 From: Fitz Elliott <fitz.elliott@gmail.com> Date: Tue, 30 Oct 2012 12:13:44 -0400 Subject: [PATCH] add test for compile time warnings --- t/compile-time.t | 7 ++++++- t/lib/CompileTime.pm | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/t/compile-time.t b/t/compile-time.t index 90debf2..67297d0 100644 --- a/t/compile-time.t +++ b/t/compile-time.t @@ -4,6 +4,11 @@ use warnings; use lib 't/lib'; use Test::More; -use_ok('CompileTime'); +BEGIN { + require Test::NoWarnings; + use_ok('CompileTime'); +} + +Test::NoWarnings->had_no_warnings(); done_testing; diff --git a/t/lib/CompileTime.pm b/t/lib/CompileTime.pm index 925bc18..1c16739 100644 --- a/t/lib/CompileTime.pm +++ b/t/lib/CompileTime.pm @@ -10,6 +10,7 @@ BEGIN { my $stash = Package::Stash->new(__PACKAGE__); $stash->add_symbol('$bar', $foo); $stash->add_symbol('$baz', $stash->get_symbol('$foo')); + $stash->get_or_add_symbol('$quux'); } 1; -- 1.8.0
This appears to have been unknowingly fixed in 0.26. I've added a test to the repository to ensure that it doesn't start happening again.