Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporter::Tiny won't export '%FLAVOR' or '@FLAVOR' if its exporting 'FLAVOR' #9

Closed
djerius opened this issue Sep 29, 2022 · 1 comment
Labels

Comments

@djerius
Copy link

djerius commented Sep 29, 2022

Exporter::Tiny->VERSION version 1.004002

Howdy.

Here's some example code illustrating some (questionable, but actual) code which wishes to export @FLAVOR, %FLAVOR, and FLAVOR:

package MyExporter;

use strict;
use warnings;

use if $ENV{USE_EXPORTER_TINY}, base => 'Exporter::Tiny';
use if !$ENV{USE_EXPORTER_TINY}, base => 'Exporter';

sub FLAVORS { 'CHOCOLATE', 'VANILLA'  }
our @FLAVORS     = ( 'chocolate', 'vanilla' );
our %FLAVORS     = ( best => 'chocolate', second_best => 'vanilla' );
our @EXPORT_OK   = ( 'FLAVORS', '@FLAVORS', '%FLAVORS' );
our %EXPORT_TAGS = ( all => \@EXPORT_OK );

and it's driver:

use v5.10;
use strict;
use warnings;

use Data::Dumper;
use lib './dev';

use MyExporter ':all';

say Dumper \@FLAVORS;
say Dumper \%FLAVORS;
say Dumper [ FLAVORS() ];

And here's what happens with plain 'ol Exporter:

$ USE_EXPORTER_TINY=0 perl dev/exporter_tiny.pl
$VAR1 = [
          'chocolate',
          'vanilla'
        ];

$VAR1 = {
          'best' => 'chocolate',
          'second_best' => 'vanilla'
        };

$VAR1 = [
          'CHOCOLATE',
          'VANILLA'
        ];

Now, with Exporter::Tiny:

$ USE_EXPORTER_TINY=1 perl dev/exporter_tiny.pl
Variable "@FLAVORS" is not imported at dev/exporter_tiny.pl line 11.
	(Did you mean &FLAVORS instead?)
Variable "%FLAVORS" is not imported at dev/exporter_tiny.pl line 12.
	(Did you mean &FLAVORS instead?)
Global symbol "@FLAVORS" requires explicit package name (did you forget to declare "my @FLAVORS"?) at dev/exporter_tiny.pl line 11.
Global symbol "%FLAVORS" requires explicit package name (did you forget to declare "my %FLAVORS"?) at dev/exporter_tiny.pl line 12.
Execution of dev/exporter_tiny.pl aborted due to compilation errors.

I expect Exporter::Tiny and Exporter to respond equivalently.

@djerius djerius changed the title Exporter::Tiny won't export '%FLAVOR' or '@FLAVOR' if it's exporting 'FLAVOR' Exporter::Tiny won't export '%FLAVOR' or '@FLAVOR' if its exporting 'FLAVOR' Sep 29, 2022
@tobyink tobyink added the bug label Sep 30, 2022
@tobyink tobyink closed this as completed Sep 30, 2022
@djerius
Copy link
Author

djerius commented Sep 30, 2022

Thanks!

clrpackages pushed a commit to clearlinux-pkgs/perl-Exporter-Tiny that referenced this issue Sep 30, 2022
…2 to version 1.004003

1.004003	2022-09-30

 [ Bug Fixes ]
 - If exporting non-CODE items which happen to have the same name as
   exported CODE items, their export was being quietly blocked. These
   exports should now work.
   Diab Jerius++
   <tobyink/p5-exporter-tiny#9>
 - Using ! with a tag now works; it was previously documented as working
   but not implemented.
   Diab Jerius++
   <tobyink/p5-exporter-tiny#8>
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Oct 1, 2022
Upstream changes:
1.004003        2022-09-30

 [ Bug Fixes ]
 - If exporting non-CODE items which happen to have the same name as
   exported CODE items, their export was being quietly blocked. These
   exports should now work.
   Diab Jerius++
   <tobyink/p5-exporter-tiny#9>
 - Using ! with a tag now works; it was previously documented as working
   but not implemented.
   Diab Jerius++
   <tobyink/p5-exporter-tiny#8>

1.004002        2022-09-16

 [ Test Suite ]
 - Fix for t/15nonhashvalue.t on old versions of Test::More which don't
   support `done_testing`.

1.004001        2022-09-09

 [ Bug Fixes ]
 - Fix handling of non-hashref references in import list.

1.004000        2022-08-26

 [ Documentation ]
 - Document that the `-lexical` export option is experimental.

 [ Packaging ]
 - No functional changes; repackage as stable.

1.003_002       2022-08-18

 [ Bug Fixes ]
 - Quote $1 when passing it as a parameter to a function
   Eugen Konkov++
   <tobyink/p5-exporter-tiny#7>

1.003_001       2022-07-21

 [ Bug Fixes ]
 - Correctly check Perl version is at least 5.37.2+ before supporting
   -lexical option.

1.003_000       2022-07-21

 - Updated: Provide a `-lexical` export option on Perl 5.37.2+.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants