Perl has limited support for checking static code, in particular, it can check whether we pass the appropriate number of arguments to a function. For example, this will result in an error:
use strict;
use warnings;
sub f($) {}
f(2, 3)
Too many arguments for main::f
If we try to call f too early, we get another useful warning:
use strict;
use warnings;
f(2, 3)
sub f($) {}
main::f() called too early to check prototype
This will result in an error:
use strict;
use warnings;
sub f($) {}
sub g() { f(2, 3) }
Too many arguments for main::f
And my question is, is it possible to get such a message for the following scenario:
use strict;
use warnings;
sub g() { f(2, 3) }
sub f($) {}
Because I do not receive any errors or warnings. It would be nice if I could prevent this code from compiling. Please inform.
source
share