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

General subroutine breakage, test failures under perl 5.41.9 #4

Open
mauke opened this issue Feb 20, 2025 · 5 comments
Open

General subroutine breakage, test failures under perl 5.41.9 #4

mauke opened this issue Feb 20, 2025 · 5 comments

Comments

@mauke
Copy link

mauke commented Feb 20, 2025

This module throws errors for various types of subroutines.

  • Declared (but not defined) subs:
    $ perl -wle 'use Symbol::Get; sub foo; print Symbol::Get::get("&foo")'
    Can't use string ("-1") as a symbol ref while "strict refs" in use at /home/mauke/perl5/perlbrew/perls/perl-5.40.1/lib/site_perl/5.40.1/Symbol/Get.pm line 101.
    
  • Declared (but not defined) subs with a prototype:
    $ perl -wle 'use Symbol::Get; { package Bar; sub foo ($@); } print Symbol::Get::get("&Bar::foo")'
    Can't use string ("$@") as a symbol ref while "strict refs" in use at /home/mauke/perl5/perlbrew/perls/perl-5.40.1/lib/site_perl/5.40.1/Symbol/Get.pm line 101.
    
  • All subroutines in package main:
    $ perl -wle 'use Symbol::Get; sub foo { 42 } print Symbol::Get::get("&foo")'
    Not a GLOB reference at /home/mauke/perl5/perlbrew/perls/perl-5.40.1/lib/site_perl/5.40.1/Symbol/Get.pm line 101.
    

None of these are covered by the test suite of Symbol::Get. But starting with perl 5.41.9, this latter error occurs for subroutines in all packages, not just main. This is due to a change in the way perl stores subs: If possible, it stores a coderef directly in the stash, without allocating a typeglob wrapper. That is, $Bar::{foo} is now a CODE reference, not a GLOB with a CODE slot. (This was already the case for package main since perl 5.22, but now it happens for all packages.)

This is why tests have started failing with recent development versions of perl:

t/001_load.t ... ok
Not a GLOB reference at /home/mauke/.cpan/build/Symbol-Get-0.12-0/blib/lib/Symbol/Get.pm line 101.
# Looks like your test exited with 255 just after 4.
t/002_usage.t .. 
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 12/16 subtests 
@FGasper
Copy link
Owner

FGasper commented Feb 20, 2025

@mauke Thanks for the bug report.

Would a fix be just to check for a CODE reference as well as the glob?

@mauke
Copy link
Author

mauke commented Feb 20, 2025

For the test failures, yes.

For the first two errors, the stash just stores -1 or the subroutine prototype (as a string), so I'm not sure how you'd want to handle that.

@FGasper
Copy link
Owner

FGasper commented Feb 20, 2025

TBH in all my years of using Perl I think I neither saw nor used subroutine declarations. I’m inclined just to say “not supported”, particularly since my use of Perl is rare these days.

@FGasper
Copy link
Owner

FGasper commented Feb 21, 2025

@mauke Do you know when a Docker image will be made with 5.41.10?

@mauke mauke changed the title General subroutine breakage, test failures under perl 5.41.10 General subroutine breakage, test failures under perl 5.41.9 Feb 21, 2025
@mauke
Copy link
Author

mauke commented Feb 21, 2025

Oops, the next perl version to be released is 5.41.9, not 5.41.10.

Perl 5.41.9 was originally planned to be released on 2025-02-20, which didn't happen, but I expect a release in the very near future. After that, it needs to be added to https://github.com/Perl/docker-perl/commits/master/config.yml. I don't know an exact date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants