Skip to content

bad diagnostic for 'catch (my $e)': Can't redeclare "my" in "our" #23222

Closed

Description

@mauke

Description

If you try to explicitly declare the exception variable of a catch block, you get a nonsensical error: Can't redeclare "my" in "our" at -e line 1, near "(my"
But there is no our declaration to be seen.

Steps to Reproduce

$ ./perl -Ilib -e 'use feature qw(try); try {} catch (my $e) {}'
Can't redeclare "my" in "our" at -e line 1, near "(my"
syntax error at -e line 1, near "(my "
Execution of -e aborted due to compilation errors.

Expected behavior

$ ./perl -Ilib -e 'use feature qw(try); try {} catch (my $e) {}'
syntax error at -e line 1, near "(my "
Execution of -e aborted due to compilation errors.

Or maybe something better than just syntax error. The point is, Can't redeclare ... shouldn't be there because there is no our (my $e) in the code.

Perl configuration

... shouldn't really matter. I get the same output from perl 5.34.1, 5.36.0, 5.38.2, 5.40.2, and blead @ 6c95af2.

Activity

  1. added 3 commits that reference this issue on Apr 28, 2025
    6059148
    70dae7c
    0108915
  2. added a commit that references this issue on Jul 28, 2025
    c43d779
  3. added a commit that references this issue on Jul 28, 2025
    88ff8da
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions