From: James Mastros Date: Fri, 23 Apr 2010 09:35:28 +0000 (+0200) Subject: New deprecation warning: Dot after %s literal is concatenation X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6fb472bab4fadd0ae2ca9624b74596afab4fb8cb;p=p5sagit%2Fp5-mst-13.2.git New deprecation warning: Dot after %s literal is concatenation --- diff --git a/pod/perldiag.pod b/pod/perldiag.pod index edccac1..fe9be76 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -1524,6 +1524,17 @@ you called it with no args and both C<$@> and C<$_> were empty. See Server error. +=item Dot after %s literal is concatenation + +(D) You had something like 0x123.456 in your code. This is currently +parsed as the hexadecimal number 0x123 concatenated with the decimal +number 456, not 0x123 + 0x456/0x1000 -- we only support decimal +decimal points. If you meant it to be a fraction, you'll need to use +Math::BigFloat's from_hex (or friends). If you meant it to be +concatenation, just put spaces around the dot to make it clearer. In +5.14.0, we expect to change this to mean a hex fraction. (Of course, +everything above applies to octal and binary constants, too.) + =item %s does not define %s::VERSION--version check failed (F) You said something like "use Module 42" but the Module did not diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke index 2236442..914c988 100644 --- a/t/lib/warnings/toke +++ b/t/lib/warnings/toke @@ -960,3 +960,20 @@ Use of := for an empty attribute list is deprecated at - line 36. Use of := for an empty attribute list is deprecated at - line 38. Use of := for an empty attribute list is deprecated at - line 41. Use of := for an empty attribute list is deprecated at - line 42. +######## +# toke.c +use warnings 'deprecation'; +my $a = 0123.456; +my $b = 0x123.456; +my $c = 0b101.010; +no warnings 'deprecation'; +my $d = 0765.432; +EXPECT +Dot after octal literal is concatenation at - line 1. +Dot after hex literal is concatenation at - line 2. +Dot after binary literal is concatenation at - line 3. +######## +# toke.c +use warnings; +my @c = 0x123..0x456; +EXPECT diff --git a/toke.c b/toke.c index b5236da..7abcfb7 100644 --- a/toke.c +++ b/toke.c @@ -13117,6 +13117,15 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp) Perl_ck_warner(aTHX_ packWARN(WARN_SYNTAX), "Misplaced _ in number"); } + /* Dot here is historically concat, not a radix point. + Deprecate that; it's confusing, and gets in the way of + hex(ish) fractions... but '..' is OK. */ + if (s[0] == '.' && + s[1] != '.') { + Perl_ck_warner(aTHX_ packWARN(WARN_DEPRECATED), + "Dot after %s literal is concatenation", base); + } + sv = newSV(0); if (overflowed) { if (n > 4294967295.0)