Skip to content

Commit b2583b0

Browse files
committed
Ensure that warning about variable shadowing mentions fields correctly
1 parent b168912 commit b2583b0

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

pad.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,7 @@ S_pad_check_dup(pTHX_ PADNAME *name, U32 flags, const HV *ourstash)
899899
( is_our ? "our" :
900900
PL_parser->in_my == KEY_my ? "my" :
901901
PL_parser->in_my == KEY_sigvar ? "my" :
902+
PL_parser->in_my == KEY_field ? "field" :
902903
"state" ),
903904
*PadnamePV(pn) == '&' ? "subroutine" : "variable",
904905
PNfARG(pn),

t/lib/warnings/class

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,14 @@ C->new(1,2,3);
2222
EXPECT
2323
Odd number of arguments passed to C constructor at - line 7.
2424
Odd number of arguments passed to C constructor at - line 9.
25+
########
26+
# field shadowing warning
27+
use v5.36;
28+
use feature 'class';
29+
no warnings 'experimental::class';
30+
class C {
31+
field $x;
32+
field $x;
33+
}
34+
EXPECT
35+
"field" variable $x masks earlier declaration in same scope at - line 7.

0 commit comments

Comments
 (0)