Bug#931418: perl: no errors with strict subs and bareword following a minus operator
Niko Tyni
ntyni at debian.org
Thu Jul 4 14:57:22 BST 2019
On Thu, Jul 04, 2019 at 02:10:22PM +0200, Vincent Lefevre wrote:
> Package: perl
> Version: 5.28.1-6
> Severity: normal
>
> The following does no yield any error:
>
> perl -e 'use strict; my $x = - Inf;'
>
> This does not seem to be intended.
Inf is not special here, other strings behave similarly.
Googling a bit turns up
https://stackoverflow.com/questions/23215511/ambiguous-use-of-constant-resolved-as-constant
https://www.perlmonks.org/?node_id=1047125
and the following passage in perlop:
Unary "-" performs arithmetic negation if the operand is numeric,
including any string that looks like a number. If the operand is an
identifier, a string consisting of a minus sign concatenated with
the identifier is returned.
So it looks like this is intentional or at least documented
behaviour that we're stuck with.
--
Niko Tyni ntyni at debian.org
More information about the Perl-maintainers
mailing list