diff options
author | Karl Williamson <khw@khw-desktop.(none)> | 2010-06-09 14:40:14 -0600 |
---|---|---|
committer | David Golden <dagolden@cpan.org> | 2010-06-18 18:43:03 -0400 |
commit | e6897b1a5db0410e387ccbf677e89fc4a1d8c97a (patch) | |
tree | 6bde58df5125be7b350ea94874255b04b1f053ea | |
parent | d9bf0e0a91525fcdd8099d78b891aa20066e9d1c (diff) | |
download | perl-e6897b1a5db0410e387ccbf677e89fc4a1d8c97a.tar.gz |
Deprecate no space between pattern, following word
This patch raises a deprecated warning on constructs like
$result = $a =~ m/$foo/sand $bar;
which means
$result = $a =~ m/$foo/s and $bar;
-rw-r--r-- | pod/perldiag.pod | 18 | ||||
-rw-r--r-- | t/lib/warnings/toke | 5 | ||||
-rw-r--r-- | toke.c | 6 |
3 files changed, 27 insertions, 2 deletions
diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 4d7d6adce8..26c35a0c30 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -1913,6 +1913,23 @@ spots. This is now heavily deprecated. (F) The parser has given up trying to parse the program after 10 errors. Further error messages would likely be uninformative. +=item Having no space between pattern and following word is deprecated + +(D syntax) + +You had a word that isn't a regex modifier immediately following a pattern +without an intervening space. For example, the two constructs: + + $a =~ m/$foo/sand $bar + $a =~ m/$foo/s and $bar + +both currently mean the same thing, but it is planned to disallow the first form +in Perl 5.16. And, + + $a =~ m/$foo/and $bar + +will be disallowed too. + =item Hexadecimal number > 0xffffffff non-portable (W portable) The hexadecimal number you specified is larger than 2**32-1 @@ -2855,7 +2872,6 @@ your system. (F) The indicated command line switch needs a mandatory argument, but you haven't specified one. - =item No such class field "%s" in variable %s of type %s (F) You tried to access a key from a hash through the indicated typed variable diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke index 223644236b..6a1a6a579c 100644 --- a/t/lib/warnings/toke +++ b/t/lib/warnings/toke @@ -140,13 +140,16 @@ Use of comma-less variable list is deprecated at - line 4. Use of comma-less variable list is deprecated at - line 4. ######## # toke.c +$a =~ m/$foo/sand $bar; $a = <<; no warnings 'deprecated' ; +$a =~ m/$foo/sand $bar; $a = <<; EXPECT -Use of bare << to mean <<"" is deprecated at - line 2. +Having no space between pattern and following word is deprecated at - line 2. +Use of bare << to mean <<"" is deprecated at - line 3. ######## # toke.c use warnings 'syntax' ; @@ -11887,6 +11887,12 @@ S_scan_pat(pTHX_ char *start, I32 type) #endif while (*s && strchr(valid_flags, *s)) pm->op_pmflags = S_pmflag(pm->op_pmflags, *s++); + + if (isALNUM(*s)) { + Perl_ck_warner_d(aTHX_ packWARN(WARN_SYNTAX), + "Having no space between pattern and following word is deprecated"); + + } #ifdef PERL_MAD if (PL_madskills && modstart != s) { SV* tmptoken = newSVpvn(modstart, s - modstart); |