Skip to content

Conversation

@mauke
Copy link
Contributor

@mauke mauke commented Jul 31, 2025

This fixes the TODO test in t/op/anonsub.t, but breaks two other tests:

  • t/op/anonsub.t

      not ok 12 - '{ $x = sub }' is illegal
      # Failed test 12 - '{ $x = sub }' is illegal at t/op/anonsub.t line 15
      #      got 'Global symbol \"$x\" requires explicit package name (did you forget to declare \"my $x\"?) at (eval 12) line 1, <DATA> line 87.\nIllegal declaration of anonymous subroutine at (eval 12) line 1, at EOF\n'
      # expected /(?^:^Illegal declaration of anonymous subroutine at)/
    
  • t/lib/croak.t

      FILE: lib/croak/toke ; line 644
      PROG:
      no feature 'apostrophe_as_package_separator';
      sub 'Hello'_he_said (_);
      EXPECTED:
      Illegal declaration of anonymous subroutine at - line 2.
      EXIT STATUS: != 0
      GOT:
      Bareword found where operator expected (Missing operator before "_he_said"?) at - line 2, near "'Hello'_he_said"
      Illegal declaration of anonymous subroutine at - line 2, near "sub 'Hello'"
      Execution of - aborted due to compilation errors.
      EXIT STATUS: 255
      not ok 247 - tick in names: initial character of sub name (no feature)
      # Failed test 247 - tick in names: initial character of sub name (no feature) at lib/croak/toke line 644
    

Since we don't immediately error out from the lexer anymore, the parser may accumulate more errors before failing with "Illegal declaration of anonymous subroutine".

See #5959.


  • This set of changes requires a perldelta entry, and it is included.
  • This set of changes requires a perldelta entry, and I need help writing it.
  • This set of changes does not require a perldelta entry.

mauke added 2 commits August 3, 2025 13:50
This fixes the TODO test in t/op/anonsub.t, but breaks two other tests:

- t/op/anonsub.t

        not ok 12 - '{ $x = sub }' is illegal
        # Failed test 12 - '{ $x = sub }' is illegal at t/op/anonsub.t line 15
        #      got 'Global symbol \"$x\" requires explicit package name (did you forget to declare \"my $x\"?) at (eval 12) line 1, <DATA> line 87.\nIllegal declaration of anonymous subroutine at (eval 12) line 1, at EOF\n'
        # expected /(?^:^Illegal declaration of anonymous subroutine at)/

- t/lib/croak.t

        FILE: lib/croak/toke ; line 644
        PROG:
        no feature 'apostrophe_as_package_separator';
        sub 'Hello'_he_said (_);
        EXPECTED:
        Illegal declaration of anonymous subroutine at - line 2.
        EXIT STATUS: != 0
        GOT:
        Bareword found where operator expected (Missing operator before "_he_said"?) at - line 2, near "'Hello'_he_said"
        Illegal declaration of anonymous subroutine at - line 2, near "sub 'Hello'"
        Execution of - aborted due to compilation errors.
        EXIT STATUS: 255
        not ok 247 - tick in names: initial character of sub name (no feature)
        # Failed test 247 - tick in names: initial character of sub name (no feature) at lib/croak/toke line 644

Since we don't immediately error out from the lexer anymore, the parser
may accumulate more errors before failing with "Illegal declaration of
anonymous subroutine".

The tests have been changed to accomodate the new diagnostics.

Fixes Perl#5959.
@mauke mauke force-pushed the fix-5959-illegal-anon-sub branch from ed35b0d to e8508b0 Compare August 3, 2025 12:05
@mauke mauke merged commit fd80e1a into Perl:blead Aug 4, 2025
33 checks passed
@mauke mauke deleted the fix-5959-illegal-anon-sub branch August 4, 2025 07:55
khwilliamson added a commit to khwilliamson/perl5 that referenced this pull request Aug 9, 2025
This fixes Perl#23519

When something goes wrong doing locale-aware string collation, the code
attempts to carry on as well as can be expected.  Prior to this commit
the backout code was asymmetric, trying to undo things that had not been
done.  This happened when the failure was early on.

In the case of this ticket, the platform has a defective locale that was
detectable before getting very far along.

The solution adopted here is to jump to a different label for those
early failures that does less backout than for later failures.
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

Successfully merging this pull request may close these issues.

2 participants