[latex3-commits] [git/latex3] master: For N to o and n to c variant changes, only produce a warning (see #418) (d0978ec)
Bruno Le Floch
bruno at le-floch.fr
Mon Nov 27 23:20:51 CET 2017
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/d0978ecba89b0df3b80bda5cbedf6a25f35fe059
>---------------------------------------------------------------
commit d0978ecba89b0df3b80bda5cbedf6a25f35fe059
Author: Bruno Le Floch <bruno at le-floch.fr>
Date: Mon Nov 27 16:10:46 2017 -0500
For N to o and n to c variant changes, only produce a warning (see #418)
Third-party code would otherwise break.
>---------------------------------------------------------------
d0978ecba89b0df3b80bda5cbedf6a25f35fe059
l3kernel/l3expan.dtx | 24 +++++++++
l3kernel/testfiles/m3expan001.tlg | 84 +++++++++----------------------
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 +
12 files changed, 59 insertions(+), 59 deletions(-)
diff --git a/l3kernel/l3expan.dtx b/l3kernel/l3expan.dtx
index 744a11d..5e347e9 100644
--- a/l3kernel/l3expan.dtx
+++ b/l3kernel/l3expan.dtx
@@ -1710,6 +1710,7 @@
% \@@_generate_variant_loop_end:nwwwNNnn,
% \@@_generate_variant_loop_long:wNNnn,
% \@@_generate_variant_loop_invalid:NNwNNnn,
+% \@@_generate_variant_loop_special:NNwNNnn
% }
% \begin{arguments}
% \item Last few consecutive letters common between the base and
@@ -1762,12 +1763,26 @@
% breaking function takes the empty brace group in |#4| as its first
% argument: this empty brace group produces the correct signature for
% the full variant.
+%
+% Since people seem to have tried generating |c|-type variants of
+% |n|-type arguments, and |o|-type variants of |N|-type arguments, in
+% those cases we only produce a warning. Once we have waited long
+% enough the first construction involving
+% \cs{@@_generate_variant_loop_special:NNwNNnn} should be removed.
% \begin{macrocode}
\cs_new:Npn \@@_generate_variant_loop:nNwN #1#2#3 \q_mark #4
{
\if:w #2 #4
\exp_after:wN \@@_generate_variant_loop_same:w
\else:
+ \if:w 0
+ \if:w n #4 \if:w c #2 1 \fi: \fi:
+ \if:w N #4 \if:w o #2 1 \fi: \fi:
+ 0
+ \else:
+ \@@_generate_variant_loop_special:NNwNNnn #4#2
+ \exp_after:wN \reverse_if:N
+ \fi:
\if:w #4
\if:w c #2 N \else:
\if:w o #2 n \else:
@@ -1833,6 +1848,15 @@
#5
}
}
+\cs_new:Npn \@@_generate_variant_loop_special:NNwNNnn #1#2#3 \q_stop #4#5#6#7
+ {
+ #3 \q_stop #4 #5 {#6} {#7}
+ \exp_not:n
+ {
+ \__msg_kernel_warning:nnxxxx { kernel } { invalid-variant }
+ {#7} { \token_to_str:N #5 } {#1} {#2}
+ }
+ }
% \end{macrocode}
% \end{macro}
%
diff --git a/l3kernel/testfiles/m3expan001.tlg b/l3kernel/testfiles/m3expan001.tlg
index 89c2aa6..264bc3e 100644
--- a/l3kernel/testfiles/m3expan001.tlg
+++ b/l3kernel/testfiles/m3expan001.tlg
@@ -11,25 +11,17 @@ Defining \foo:nn on line ...
Defining \foo:oo on line ...
Defining \foo:VV on line ...
Defining \foo:xx on line ...
-Variant \foo:nn already defined; not changing it on line ...
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-!
-! LaTeX error: "kernel/invalid-variant"
-!
-! Variant form 'cc' invalid for base form '\foo:nn'.
-!
-! See the LaTeX3 documentation for further information.
-!
-! For immediate help type H <return>.
-!...............................................
-l. ... { oo , VV , xx , cc , nx , fx , xf }
-|'''''''''''''''''''''''''''''''''''''''''''''''
-| This is a coding error.
-|
-| LaTeX has been asked to create a variant of the function '\foo:nn' with a
-| signature starting with 'cc', but cannot change an argument from type 'n' to
-| type 'c'.
-|...............................................
+Defining \foo:cc on line ...
+*************************************************
+* LaTeX warning: "kernel/invalid-variant"
+*
+* Variant form 'cc' invalid for base form '\foo:nn'.
+*************************************************
+*************************************************
+* LaTeX warning: "kernel/invalid-variant"
+*
+* Variant form 'cc' invalid for base form '\foo:nn'.
+*************************************************
Defining \foo:nx on line ...
Defining \exp_args:Nfx on line ...
Defining \foo:fx on line ...
@@ -44,7 +36,7 @@ TEST 1: protection
\long macro:->\exp_args:Noo \foo:nn
\long macro:->\exp_args:NVV \foo:nn
\protected\long macro:->\exp_args:Nxx \foo:nn
-undefined
+\long macro:->\exp_args:Ncc \foo:nn
\protected\long macro:->\exp_args:Nnx \foo:nn
\protected\long macro:->\exp_args:Nfx \foo:nn
\protected\long macro:->\exp_args:Nxf \foo:nn
@@ -247,44 +239,18 @@ undefined,undefined,
============================================================
TEST 10: Issue 418: changing N/n to incompatible variants
============================================================
-Variant \foobar:Nn 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:Nn 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'.
-|...............................................
+Defining \foobar:on on line ...
+*************************************************
+* LaTeX warning: "kernel/invalid-variant"
+*
+* Variant form 'on' invalid for base form '\foobar:Nn'.
+*************************************************
+Defining \foobar:Nc on line ...
+*************************************************
+* LaTeX warning: "kernel/invalid-variant"
+*
+* Variant form 'Nc' invalid for base form '\foobar:Nn'.
+*************************************************
Variant \foobar:Nn already defined; not changing it on line ...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
@@ -304,5 +270,5 @@ l. ... }
| signature starting with 'n', but cannot change an argument from type 'N' to
| type 'n'.
|...............................................
-undefined,undefined,undefined,
+\long macro:->\exp_args:No \foobar:Nn ,\long macro:->\exp_args:NNc \foobar:Nn ,undefined,
============================================================
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index c3c5315..c933d13 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -250,6 +250,7 @@ Defining \__cs_generate_variant_loop_same:w on line ...
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_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 3d89993..f14e3d5 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -249,6 +249,7 @@ Defining \__cs_generate_variant_loop_same:w on line ...
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_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 506a502..853492c 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -249,6 +249,7 @@ Defining \__cs_generate_variant_loop_same:w on line ...
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_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 8593c67..d36c769 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -249,6 +249,7 @@ Defining \__cs_generate_variant_loop_same:w on line ...
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_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 3317465..2ee11d1 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -249,6 +249,7 @@ Defining \__cs_generate_variant_loop_same:w on line ...
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_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 c3c5315..c933d13 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -250,6 +250,7 @@ Defining \__cs_generate_variant_loop_same:w on line ...
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_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 3d89993..f14e3d5 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -249,6 +249,7 @@ Defining \__cs_generate_variant_loop_same:w on line ...
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_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 506a502..853492c 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -249,6 +249,7 @@ Defining \__cs_generate_variant_loop_same:w on line ...
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_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 8593c67..d36c769 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -249,6 +249,7 @@ Defining \__cs_generate_variant_loop_same:w on line ...
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_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 3317465..2ee11d1 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -249,6 +249,7 @@ Defining \__cs_generate_variant_loop_same:w on line ...
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_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