[latex3-commits] [git/latex3] master: Use normal deprecation system for \cs_generate_variant:Nn cases (fixes #418) (8357afd)

Bruno Le Floch bruno at le-floch.fr
Tue Nov 28 16:33:56 CET 2017


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/8357afd05ef29e59ad976a821a703655caa2cd16

>---------------------------------------------------------------

commit 8357afd05ef29e59ad976a821a703655caa2cd16
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Tue Nov 28 10:33:56 2017 -0500

    Use normal deprecation system for \cs_generate_variant:Nn cases (fixes #418)
    
    This commit ensures that \debug_on:n { deprecation } turns warnings into
    errors for cases where people try to turn n to N/c or N to n/o/V/v/f/x
    arguments.


>---------------------------------------------------------------

8357afd05ef29e59ad976a821a703655caa2cd16
 l3kernel/l3deprecation.dtx              |   19 ++++++++++
 l3kernel/l3expan.dtx                    |    7 +++-
 l3kernel/testfiles/m3expan001.lvt       |   13 +++++++
 l3kernel/testfiles/m3expan001.tlg       |   62 +++++++++++++++++++++++++++++++
 l3kernel/testfiles/m3expl001.luatex.tlg |    1 +
 l3kernel/testfiles/m3expl001.ptex.tlg   |    1 +
 l3kernel/testfiles/m3expl001.tlg        |    1 +
 l3kernel/testfiles/m3expl001.uptex.tlg  |    1 +
 l3kernel/testfiles/m3expl001.xetex.tlg  |    1 +
 l3kernel/testfiles/m3expl003.luatex.tlg |    1 +
 l3kernel/testfiles/m3expl003.ptex.tlg   |    1 +
 l3kernel/testfiles/m3expl003.tlg        |    1 +
 l3kernel/testfiles/m3expl003.uptex.tlg  |    1 +
 l3kernel/testfiles/m3expl003.xetex.tlg  |    1 +
 14 files changed, 109 insertions(+), 2 deletions(-)

diff --git a/l3kernel/l3deprecation.dtx b/l3kernel/l3deprecation.dtx
index e93078b..4307bba 100644
--- a/l3kernel/l3deprecation.dtx
+++ b/l3kernel/l3deprecation.dtx
@@ -117,6 +117,25 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% This is left-over from \pkg{l3expan}.  It cannot be done there because
+% \pkg{l3tl} is not loaded at that time.
+%    \begin{macrocode}
+\__debug:TF
+  {
+    \tl_gput_right:Nn \g__debug_deprecation_on_tl
+      {
+        \cs_set_protected:Npn \__cs_generate_variant_loop_warning:nnxxxx
+          { \__msg_kernel_error:nnxxxx }
+      }
+    \tl_gput_right:Nn \g__debug_deprecation_off_tl
+      {
+        \cs_set_protected:Npn \__cs_generate_variant_loop_warning:nnxxxx
+          { \__msg_kernel_warning:nnxxxx }
+      }
+  }
+  { }
+%    \end{macrocode}
+%
 %    \begin{macrocode}
 %</initex|package>
 %    \end{macrocode}
diff --git a/l3kernel/l3expan.dtx b/l3kernel/l3expan.dtx
index 01ba894..af56a7d 100644
--- a/l3kernel/l3expan.dtx
+++ b/l3kernel/l3expan.dtx
@@ -1730,7 +1730,8 @@
 %     \@@_generate_variant_loop_end:nwwwNNnn,
 %     \@@_generate_variant_loop_long:wNNnn,
 %     \@@_generate_variant_loop_invalid:NNwNNnn,
-%     \@@_generate_variant_loop_special:NNwNNnn
+%     \@@_generate_variant_loop_special:NNwNNnn,
+%     \@@_generate_variant_loop_warning:nnxxxx
 %   }
 %   \begin{arguments}
 %     \item Last few consecutive letters common between the base and
@@ -1887,10 +1888,12 @@
     #3 \q_stop #4 #5 {#6} {#7}
     \exp_not:n
       {
-        \__msg_kernel_warning:nnxxxx { kernel } { invalid-variant }
+        \@@_generate_variant_loop_warning:nnxxxx { kernel } { invalid-variant }
           {#7} { \token_to_str:N #5 } {#1} {#2}
       }
   }
+\cs_new_protected:Npn \@@_generate_variant_loop_warning:nnxxxx
+  { \__msg_kernel_warning:nnxxxx }
 %    \end{macrocode}
 % \end{macro}
 %
diff --git a/l3kernel/testfiles/m3expan001.lvt b/l3kernel/testfiles/m3expan001.lvt
index 0ab3023..f975731 100644
--- a/l3kernel/testfiles/m3expan001.lvt
+++ b/l3kernel/testfiles/m3expan001.lvt
@@ -128,4 +128,17 @@
       }
   }
 
+\debug_on:n { deprecation }
+
+\TEST { Issue~418~again }
+  {
+    \cs_generate_variant:Nn \foobar:Nn { on , Nc , n }
+    \TYPE
+      {
+        \cs_meaning:N \foobar:on ,
+        \cs_meaning:N \foobar:Nc ,
+        \cs_meaning:N \foobar:nn ,
+      }
+  }
+
 \END
diff --git a/l3kernel/testfiles/m3expan001.tlg b/l3kernel/testfiles/m3expan001.tlg
index a598aa7..1a17870 100644
--- a/l3kernel/testfiles/m3expan001.tlg
+++ b/l3kernel/testfiles/m3expan001.tlg
@@ -260,3 +260,65 @@ Defining \foobar:nn on line ...
 *************************************************
 \long macro:->\exp_args:No \foobar:Nn ,\long macro:->\exp_args:NNc \foobar:Nn ,\long macro:->\exp_args:Nn \foobar:Nn ,
 ============================================================
+============================================================
+TEST 11: Issue 418 again
+============================================================
+Variant \foobar:on already defined; not changing it on line ...
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "kernel/invalid-variant"
+! 
+! Variant form 'on' invalid for base form '\foobar:Nn'.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| LaTeX has been asked to create a variant of the function '\foobar:Nn' with a
+| signature starting with 'on', but cannot change an argument from type 'N' to
+| type 'o'.
+|...............................................
+Variant \foobar:Nc already defined; not changing it on line ...
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "kernel/invalid-variant"
+! 
+! Variant form 'Nc' invalid for base form '\foobar:Nn'.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| LaTeX has been asked to create a variant of the function '\foobar:Nn' with a
+| signature starting with 'Nc', but cannot change an argument from type 'n' to
+| type 'c'.
+|...............................................
+Variant \foobar:nn already defined; not changing it on line ...
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "kernel/invalid-variant"
+! 
+! Variant form 'n' invalid for base form '\foobar:Nn'.
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| This is a coding error.
+| 
+| LaTeX has been asked to create a variant of the function '\foobar:Nn' with a
+| signature starting with 'n', but cannot change an argument from type 'N' to
+| type 'n'.
+|...............................................
+\long macro:->\exp_args:No \foobar:Nn ,\long macro:->\exp_args:NNc \foobar:Nn ,\long macro:->\exp_args:Nn \foobar:Nn ,
+============================================================
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 4b86cd2..6114e74 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -252,6 +252,7 @@ Defining \__cs_generate_variant_loop_end:nwwwNNnn on line ...
 Defining \__cs_generate_variant_loop_long:wNNnn on line ...
 Defining \__cs_generate_variant_loop_invalid:NNwNNnn on line ...
 Defining \__cs_generate_variant_loop_special:NNwNNnn on line ...
+Defining \__cs_generate_variant_loop_warning:nnxxxx on line ...
 Defining \__cs_generate_variant_same:N on line ...
 Defining \__cs_generate_variant:wwNN on line ...
 Defining \__cs_generate_internal_variant:n on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index 9f7e5a7..e1277b5 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -251,6 +251,7 @@ Defining \__cs_generate_variant_loop_end:nwwwNNnn on line ...
 Defining \__cs_generate_variant_loop_long:wNNnn on line ...
 Defining \__cs_generate_variant_loop_invalid:NNwNNnn on line ...
 Defining \__cs_generate_variant_loop_special:NNwNNnn on line ...
+Defining \__cs_generate_variant_loop_warning:nnxxxx on line ...
 Defining \__cs_generate_variant_same:N on line ...
 Defining \__cs_generate_variant:wwNN on line ...
 Defining \__cs_generate_internal_variant:n on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index 1867507..a77b8c2 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -251,6 +251,7 @@ Defining \__cs_generate_variant_loop_end:nwwwNNnn on line ...
 Defining \__cs_generate_variant_loop_long:wNNnn on line ...
 Defining \__cs_generate_variant_loop_invalid:NNwNNnn on line ...
 Defining \__cs_generate_variant_loop_special:NNwNNnn on line ...
+Defining \__cs_generate_variant_loop_warning:nnxxxx on line ...
 Defining \__cs_generate_variant_same:N on line ...
 Defining \__cs_generate_variant:wwNN on line ...
 Defining \__cs_generate_internal_variant:n on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 12d663b..99d2e67 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -251,6 +251,7 @@ Defining \__cs_generate_variant_loop_end:nwwwNNnn on line ...
 Defining \__cs_generate_variant_loop_long:wNNnn on line ...
 Defining \__cs_generate_variant_loop_invalid:NNwNNnn on line ...
 Defining \__cs_generate_variant_loop_special:NNwNNnn on line ...
+Defining \__cs_generate_variant_loop_warning:nnxxxx on line ...
 Defining \__cs_generate_variant_same:N on line ...
 Defining \__cs_generate_variant:wwNN on line ...
 Defining \__cs_generate_internal_variant:n on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index cf8d05e..6cbb39c 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -251,6 +251,7 @@ Defining \__cs_generate_variant_loop_end:nwwwNNnn on line ...
 Defining \__cs_generate_variant_loop_long:wNNnn on line ...
 Defining \__cs_generate_variant_loop_invalid:NNwNNnn on line ...
 Defining \__cs_generate_variant_loop_special:NNwNNnn on line ...
+Defining \__cs_generate_variant_loop_warning:nnxxxx on line ...
 Defining \__cs_generate_variant_same:N on line ...
 Defining \__cs_generate_variant:wwNN on line ...
 Defining \__cs_generate_internal_variant:n on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 4b86cd2..6114e74 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -252,6 +252,7 @@ Defining \__cs_generate_variant_loop_end:nwwwNNnn on line ...
 Defining \__cs_generate_variant_loop_long:wNNnn on line ...
 Defining \__cs_generate_variant_loop_invalid:NNwNNnn on line ...
 Defining \__cs_generate_variant_loop_special:NNwNNnn on line ...
+Defining \__cs_generate_variant_loop_warning:nnxxxx on line ...
 Defining \__cs_generate_variant_same:N on line ...
 Defining \__cs_generate_variant:wwNN on line ...
 Defining \__cs_generate_internal_variant:n on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index 9f7e5a7..e1277b5 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -251,6 +251,7 @@ Defining \__cs_generate_variant_loop_end:nwwwNNnn on line ...
 Defining \__cs_generate_variant_loop_long:wNNnn on line ...
 Defining \__cs_generate_variant_loop_invalid:NNwNNnn on line ...
 Defining \__cs_generate_variant_loop_special:NNwNNnn on line ...
+Defining \__cs_generate_variant_loop_warning:nnxxxx on line ...
 Defining \__cs_generate_variant_same:N on line ...
 Defining \__cs_generate_variant:wwNN on line ...
 Defining \__cs_generate_internal_variant:n on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 1867507..a77b8c2 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -251,6 +251,7 @@ Defining \__cs_generate_variant_loop_end:nwwwNNnn on line ...
 Defining \__cs_generate_variant_loop_long:wNNnn on line ...
 Defining \__cs_generate_variant_loop_invalid:NNwNNnn on line ...
 Defining \__cs_generate_variant_loop_special:NNwNNnn on line ...
+Defining \__cs_generate_variant_loop_warning:nnxxxx on line ...
 Defining \__cs_generate_variant_same:N on line ...
 Defining \__cs_generate_variant:wwNN on line ...
 Defining \__cs_generate_internal_variant:n on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 12d663b..99d2e67 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -251,6 +251,7 @@ Defining \__cs_generate_variant_loop_end:nwwwNNnn on line ...
 Defining \__cs_generate_variant_loop_long:wNNnn on line ...
 Defining \__cs_generate_variant_loop_invalid:NNwNNnn on line ...
 Defining \__cs_generate_variant_loop_special:NNwNNnn on line ...
+Defining \__cs_generate_variant_loop_warning:nnxxxx on line ...
 Defining \__cs_generate_variant_same:N on line ...
 Defining \__cs_generate_variant:wwNN on line ...
 Defining \__cs_generate_internal_variant:n on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index cf8d05e..6cbb39c 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -251,6 +251,7 @@ Defining \__cs_generate_variant_loop_end:nwwwNNnn on line ...
 Defining \__cs_generate_variant_loop_long:wNNnn on line ...
 Defining \__cs_generate_variant_loop_invalid:NNwNNnn on line ...
 Defining \__cs_generate_variant_loop_special:NNwNNnn on line ...
+Defining \__cs_generate_variant_loop_warning:nnxxxx on line ...
 Defining \__cs_generate_variant_same:N on line ...
 Defining \__cs_generate_variant:wwNN on line ...
 Defining \__cs_generate_internal_variant:n on line ...





More information about the latex3-commits mailing list