On þri 16 sep 15:20:31 2014, demerphq wrote: > If we have an invalid format conversion we should not complain it is > missing an argument: > > $ perl -wE'say sprintf "%/"' > Missing argument in sprintf at -e line 1. > Invalid conversion in sprintf: "%/" at -e line 1. > %/ > > I contend that the first warning should not be produced. If the format > conversion is unknown then it probably isn't intended to have an argument. > > > Similarly we should not warn multiple times about missing arguments in > sprintf. Once should be enough. > > perl -wE'say sprintf "%s%s"' > Missing argument in sprintf at -e line 1. > Missing argument in sprintf at -e line 1. > > > My perl -v is as follows: > > This is perl 5, version 14, subversion 2 (v5.14.2) built for > x86_64-linux-gnu-thread-multi > > Although this applies to bleadperl as well. FWIW since you mentioned this as possibly being related to my recent v5.21.1-11-g4077a6b on #p5p it's not, that's adding the "redundant" warning, as you note this has been here for a while. Although the issue you note with the multiple warnings also exists for the "redundant" warning. These classes of warnings could definitely be improved, just some general points to consider: * I think we don't want to have a warning system where we cause users to play warning whack-a-mole, if we detect issues we should display as many of them upfront as possible. I.e. if you make this mistake, wanting %s: $ ./perl -we 'printf "Hello %S"' Missing argument in printf at -e line 1. Invalid conversion in printf: "%S" at -e line 1. Hello %S I think it arguably makes more sense to warn about both the missing argument *and* the invalid converson, if you want a literal % you have to escape it, so maybe the user meant to use a real format. * I think rather than collapsing this warning and only warning once about missing arguments it would be more useful to make the warning more specific, i.e. note the difference between these two: $ ./perl -Ilib -wE 'printf "%S%/%\\"' Missing argument in printf at -e line 1. Invalid conversion in printf: "%S" at -e line 1. Missing argument in printf at -e line 1. Invalid conversion in printf: "%/" at -e line 1. Missing argument in printf at -e line 1. Invalid conversion in printf: "%\" at -e line 1. %S%/%\ IMO it would be more useful to say which invalid pseudo-format is "missing" its argument than collapsing it into one warning, possibly causing the user to play warning whack-a-mole. Finally just as an implementation detail if we were to fold these warnings getting this done requires some hacking in Perl_sv_vcatpvfn_flags, now it just parses the format/arguments as a stream and warns as it goes along, it would have to accumulate issues and spew them out all at once before it returns. --- via perlbug: queue: perl5 status: new https://rt.perl.org/Ticket/Display.html?id=122793Thread Next