This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Bare heredocs will be fatal in 5.28.
authorAbigail <abigail@abigail.be>
Fri, 18 Nov 2016 17:33:19 +0000 (18:33 +0100)
committerAbigail <abigail@abigail.be>
Mon, 16 Jan 2017 18:18:13 +0000 (19:18 +0100)
Heredocs without a terminator after the << have been deprecated
since 5.000. After more than 2 decades, it's time to retire this
construct. They will be fatal in 5.28.

pod/perldeprecation.pod
pod/perldiag.pod
t/lib/warnings/toke
t/op/heredoc.t
toke.c

index d68804f..55c2db4 100644 (file)
@@ -45,6 +45,21 @@ removing them from your code fixes the deprecation warning; and removing
 them will not influence the behaviour of your code.
 
 
+=head3 Bare here-document terminators
+
+Perl has allowed you to use a bare here-document terminator to have the
+here-document end at the first empty line. This practise was deprecated
+in Perl 5.000, and this will be a fatal error in Perl 5.28.
+
+You are encouraged to use the explictly quoted form if you wish to
+use an empty line as the terminator of the here-document:
+
+  print <<"";
+    Print this line.
+
+  # Previous blank line ends the here-document.
+
+
 =head3 Setting $/ to a reference to a non-positive integer
 
 You assigned a reference to a scalar to C<$/> where the
index 761a0b4..4beeb44 100644 (file)
@@ -6883,12 +6883,15 @@ returns no useful value.  See L<perlmod>.
 (D deprecated) The C<$[> variable (index of the first element in an array)
 is deprecated.  See L<perlvar/"$[">.
 
-=item Use of bare << to mean <<"" is deprecated
+=item Use of bare << to mean <<"" is deprecated. Its use will be fatal in Perl 5.28
 
 (D deprecated) You are now encouraged to use the explicitly quoted
 form if you wish to use an empty line as the terminator of the
 here-document.
 
+Use of a bare terminator was deprecated in Perl 5.000, and
+will be a fatal error in Perl 5.28.
+
 =item Use of /c modifier is meaningless in s///
 
 (W regexp) You used the /c modifier in a substitution.  The /c
index 3ad67e0..8044f83 100644 (file)
@@ -147,7 +147,7 @@ no warnings 'deprecated' ;
 $a = <<;
 
 EXPECT
-Use of bare << to mean <<"" is deprecated at - line 2.
+Use of bare << to mean <<"" is deprecated. Its use will be fatal in Perl 5.28 at - line 2.
 ########
 # toke.c
 $a = <<~;
@@ -155,8 +155,8 @@ $a = <<~;
 $a = <<~ ;
 
 EXPECT
-Use of bare << to mean <<"" is deprecated at - line 2.
-Use of bare << to mean <<"" is deprecated at - line 4.
+Use of bare << to mean <<"" is deprecated. Its use will be fatal in Perl 5.28 at - line 2.
+Use of bare << to mean <<"" is deprecated. Its use will be fatal in Perl 5.28 at - line 4.
 ########
 # toke.c
 $a =~ m/$foo/eq;
index 15b12d9..5166159 100644 (file)
@@ -102,7 +102,7 @@ HEREDOC
     fresh_perl_like(
         qq(<<\n\$          \n),
         # valgrind and asan reports an error between these two lines
-        qr/^Use of bare << to mean <<"" is deprecated at - line 1\.\s+Final \$/,
+        qr/^Use of bare << to mean <<"" is deprecated\. Its use will be fatal in Perl 5\.28 at - line 1\.\s+Final \$/,
         {},
         "don't use an invalid oldoldbufptr (some more)"
     );
diff --git a/toke.c b/toke.c
index 6bcd80a..9bd145d 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -9739,7 +9739,7 @@ S_scan_heredoc(pTHX_ char *s)
        else
            term = '"';
        if (! isWORDCHAR_lazy_if_safe(s, PL_bufend, UTF))
-           deprecate("bare << to mean <<\"\"");
+           deprecate_fatal_in("5.28", "Use of bare << to mean <<\"\" is deprecated");
        peek = s;
         while (
                isWORDCHAR_lazy_if_safe(peek, PL_bufend, UTF))