Skip to content

Commit

Permalink
Print discouragement warning on implicit @_ in entersub
Browse files Browse the repository at this point in the history
Warn for both `goto &SUB` tailcalls and `&SUB` in perl4 style
  • Loading branch information
leonerd committed Jan 19, 2022
1 parent 48344f7 commit cba2335
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions op.c
Original file line number Diff line number Diff line change
Expand Up @@ -15310,6 +15310,9 @@ Perl_ck_subr(pTHX_ OP *o)

PERL_ARGS_ASSERT_CK_SUBR;

if(CvSIGNATURE(PL_compcv) && !(o->op_flags & OPf_STACKED))
discourage_implicit_defgv_cvsig(o);

aop = cUNOPx(o)->op_first;
if (!OpHAS_SIBLING(aop))
aop = cUNOPx(aop)->op_first;
Expand Down
6 changes: 4 additions & 2 deletions t/op/signatures.t
Original file line number Diff line number Diff line change
Expand Up @@ -1622,8 +1622,10 @@ while(<$kh>) {
}

# implicit @_
discouraged_ok 'shift', 'shift';
discouraged_ok 'pop', 'pop';
discouraged_ok 'shift', 'shift';
discouraged_ok 'pop', 'pop';
discouraged_ok 'subroutine entry', 'goto &SUB'; # tail-call
discouraged_ok 'subroutine entry', '&SUB'; # perl4-style

# explicit @_
discouraged_ok 'shift', 'shift @_';
Expand Down

0 comments on commit cba2335

Please sign in to comment.