Skip to content

Error: "Bareword found where operator expected ... Do you need to predeclare import?" #12

@jkeenan

Description

@jkeenan

This error is seen 276 times when running the test suite in the core-p7 branch.

Examples:

dist/autouse/t/autouse ......................................... Bareword found where operator expected 
at t/autouse.t line 94, near "import MyTestModule2"
        (Do you need to predeclare import?)
String found where operator expected at t/autouse.t line 94, near "MyTestModule2 'test_function2'"
        (Do you need to predeclare MyTestModule2?)
syntax error at t/autouse.t line 94, near "import MyTestModule2 "
BEGIN not safe after errors--compilation aborted at t/autouse.t line 100.
# Looks like your test exited with 255 before it could output anything.

ext/B/t/b ...................................................... Bareword found where operator expected 
at ../../lib/threads.pm line 62, near "import overload"
        (Do you need to predeclare import?)

Relevant code:

dist/autouse/t/autouse.t

 83 SKIP: {
 84     skip "Fails in 5.15.5 and below (perl bug)", 2 if $] < 5.0150051;
 85     use warnings; local $^W = 1; no warnings 'once';
 86     my $w;
 87     local $SIG{__WARN__} = sub { $w .= shift };
 88     use autouse MyTestModule2 => 'test_function2';
 89     *MyTestModule2::test_function2 = \&test_function2;
 90     require MyTestModule2;
 91     is $w, undef,
 92        'no redefinition warning when clobbering autouse stub with new sub';
 93     undef $w;
 94     import MyTestModule2 'test_function2';
 95     is $w, undef,
 96        'no redefinition warning when clobbering autouse stub via *a=\&b';
 97 }

lib/threads.pm

  40 sub import
  41 {
...
  61         } elsif ($sym =~ /^str/i) {
  62             import overload ('""' => \&tid);
  63    
  64         } elsif ($sym =~ /^(?::all|yield)$/) {
  65             push(@EXPORT, qw(yield));
  66 
  67         } else {
  68             require Carp;
  69             Carp::croak("threads: Unknown import option: $sym");
  70         }

How do we fix?

Thank you very much.
Jim Keenan

Metadata

Metadata

Assignees

No one assigned

    Labels

    predeclare-needErrors asking "Do you need to predeclare ___?"

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions