-
Notifications
You must be signed in to change notification settings - Fork 559
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Undefined subroutine &%s called, close to label '%s'
#17839 requested a compile-time warning for the situation whereby a single colon is accdentally typed as a package separator when calling a function. For example: ``` package BOOP; sub beep; package main; BOOP:beep(); # Meant to be BOOP::beep(); ``` However, because of both Perl's syntax and the potential to populate the stash at runtime, this falls somewhere between very difficult and impossible. As an alternative, some enhanced fatal error wording was requested and these commits attempt to provide that. The above example would previously die with the message: ``` Undefined subroutine &main::beep called at ... line 4. ``` Now it dies with the message: ``` Undefined subroutine &main::beep called, close to label 'BOOP' at ... line 4. ``` For some of the same reasons mentioned, distinguishing this typo from other errors at runtime - such as the target subroutine not being present at all - is also nigh on impossible. The hope is that the error message will give some additional clue when the error is the result of a typo, without distracting the user in all other cases. As part of these commits, some common `DIE()` calls in `pp_entersub` were extracted into a new helper function, `S_croak_undefined_subroutine`, to avoid adding (and slightly reduce) cold code bloating in `pp_entersub`.
- Loading branch information
1 parent
df4d5e8
commit 73a4618
Showing
4 changed files
with
53 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters