[latex3-commits] [git/LaTeX3-latex3-latex3] main: Ensure \bool_if_p:n returns \c_true_bool or \c_false_bool (f2eeedba9)

PhelypeOleinik phelype.oleinik at latex-project.org
Wed Jun 15 06:19:03 CEST 2022


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/f2eeedba9a3b08c14424c15539d437a036ea340e

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

commit f2eeedba9a3b08c14424c15539d437a036ea340e
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Wed Jun 15 01:19:03 2022 -0300

    Ensure \bool_if_p:n returns \c_true_bool or \c_false_bool
    
    fixes #1055


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

f2eeedba9a3b08c14424c15539d437a036ea340e
 l3kernel/CHANGELOG.md           | 1 +
 l3kernel/l3prg.dtx              | 9 +++++++--
 l3kernel/testfiles/m3prg003.lvt | 2 ++
 l3kernel/testfiles/m3prg003.tlg | 3 +++
 4 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index c3f280158..a3dba6acc 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -9,6 +9,7 @@ this project uses date-based 'snapshot' version identifiers.
 
 ### Fixed
 - Made `\peek_analysis_map_inline:n` alignment-safe (gh/1090)
+- Setting a boolean to itself no longer errors (gh/1055)
 
 ## [2022-06-02]
 
diff --git a/l3kernel/l3prg.dtx b/l3kernel/l3prg.dtx
index fee482bd6..7752d4c18 100644
--- a/l3kernel/l3prg.dtx
+++ b/l3kernel/l3prg.dtx
@@ -1102,7 +1102,11 @@
 %   use a version of \cs{tl_if_single:nTF} optimized for speed since we
 %   know that an empty~|#1| is an error.  The auxiliary
 %   \cs{@@_if_p_aux:w} removes the trailing parenthesis and gets rid of
-%   any space.  For the general case, first issue a
+%   any space, then returns \cs{c_true_bool} or \cs{c_false_bool} as
+%   appropriate.  This extra work around is because in a
+%   \cs{bool_set:Nn}, the underlying \tn{chardef} turns the bool being
+%   set temporarily equal to \tn{relax}, thus assigning a boolean to
+%   itself would fail (gh/1055).  For the general case, first issue a
 %   \cs{group_align_safe_begin:} as we are using |&&| as
 %   syntax shorthand for the And operation and we need to hide it for
 %   \TeX{}.  This group is closed after \cs{@@_get_next:NN} returns
@@ -1119,7 +1123,8 @@
     \exp:w \exp_end_continue_f:w % (
     \@@_get_next:NN \use_i:nnnn #1 )
   }
-\cs_new:Npn \@@_if_p_aux:w #1 \use_i:nnnn #2#3 {#2}
+\cs_new:Npn \@@_if_p_aux:w #1 \use_i:nnnn #2#3
+  { \bool_if:NTF #2 \c_true_bool \c_false_bool }
 %    \end{macrocode}
 % \end{macro}
 %
diff --git a/l3kernel/testfiles/m3prg003.lvt b/l3kernel/testfiles/m3prg003.lvt
index 8c81de369..75c0298a0 100644
--- a/l3kernel/testfiles/m3prg003.lvt
+++ b/l3kernel/testfiles/m3prg003.lvt
@@ -111,6 +111,8 @@
   \bool_if:NTF \l_tmpa_bool \TRUE \FALSE
   \bool_const:cn { c_A_bool } { ! \l_tmpa_bool }
   \bool_if:NTF \c_A_bool \TRUE \FALSE
+  \bool_set:Nn \l_tmpa_bool { \l_tmpa_bool } % see Github issue #1055
+  \tl_show:x { \bool_if_p:n { \l_tmpa_bool } }
 }
 
 \TESTEXP{Basics~of~not~logic-code}{
diff --git a/l3kernel/testfiles/m3prg003.tlg b/l3kernel/testfiles/m3prg003.tlg
index b05e0626a..42c9119ea 100644
--- a/l3kernel/testfiles/m3prg003.tlg
+++ b/l3kernel/testfiles/m3prg003.tlg
@@ -102,6 +102,9 @@ and I'll forget about whatever was undefined.
 TRUE
 Defining \c_A_bool on line ...
 FALSE
+> \c_true_bool .
+<recently read> }
+l. ...}
 ============================================================
 ============================================================
 TEST 9: Basics of not logic-code





More information about the latex3-commits mailing list.