Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Ambiguous use of non-feature functions goes unnoticed without warnings:

$ perl -E '$x = "txt"; sub ref {return $x . "r";}; say &ref($x);' txtr $ perl -E '$x = "txt"; sub ref {return $x . "r";}; say ref($x);' $

With warnings enabled, the non-feature functions will generate warnings about ambiguous context:

$ perl -wE '$x = "txt"; sub ref {return $x . "r";}; say &ref($x);' txtr $ perl -wE '$x = "txt"; sub ref {return $x . "r";}; say ref($x);' Ambiguous call resolved as CORE::ref(), qualify as such or use & at -e line 1. $

The trouble is, enabling "feature functions" like say() via the -E command line flag (or 'use features qw(say)', or 'use v5.10', or even 'use 5.010') will not result in warnings about ambiguous context even when warnings are enabled.

$ perl -wE 'sub say {print "txt\n";}; &say("hello");' txt $ perl -wE 'sub say {print "txt\n";}; say("hello");' hello

Ambiguous functions really should warn when warnings are enabled, even if they are new "feature" functions. I've got 5.10.1 installed at the moment, so my question is, "Has the lack of warnings on feature function ambiguity been fixed in more recent perl versions?"

Replies are listed 'Best First'.
Re: No warnings on feature function ambiguity?
by Anonymous Monk on Oct 26, 2011 at 11:16 UTC