Skip to content

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

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

Open
mauke opened this issue Apr 23, 2025 · 0 comments
Open

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

mauke opened this issue Apr 23, 2025 · 0 comments

Comments

@mauke
Copy link
Contributor

mauke commented Apr 23, 2025

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.

mauke added a commit to mauke/perl5 that referenced this issue Apr 28, 2025
Previously, this would produce

    Can't redeclare "my" in "our" at -e line 1, near "(my"

Fixes Perl#23222.
mauke added a commit to mauke/perl5 that referenced this issue Apr 28, 2025
Previously, this would produce

    Can't redeclare "my" in "our" at -e line 1, near "(my"

Fixes Perl#23222.
mauke added a commit to mauke/perl5 that referenced this issue Apr 28, 2025
Previously, this would produce

    Can't redeclare "my" in "our" at -e line 1, near "(my"

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

No branches or pull requests

1 participant