Skip to content

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

@mauke

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.

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