[latex3-commits] [latex3/latex3] main: Clear fp func locally (fixes #1298) (5c9e290ea)

github at latex-project.org github at latex-project.org
Wed Oct 25 14:56:53 CEST 2023


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

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

commit 5c9e290ea3bdc167cc8bff80c682fcaaff4d45d5
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Wed Oct 25 13:56:53 2023 +0100

    Clear fp func locally (fixes #1298)


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

5c9e290ea3bdc167cc8bff80c682fcaaff4d45d5
 l3kernel/CHANGELOG.md                   |  3 +++
 l3kernel/l3fp-symbolic.dtx              |  3 ++-
 l3kernel/testfiles/m3fp-symbolic001.lvt |  9 +++++++++
 l3kernel/testfiles/m3fp-symbolic001.tlg | 10 ++++++++++
 4 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 744e32ba7..2959c8017 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -15,6 +15,9 @@ this project uses date-based 'snapshot' version identifiers.
 - Refine action of `\text_titlecase_first:n(n)` to be focussed strictly on
   first (relevant) codepoint in the input
 
+### Fixed
+- Support fp vars setting intermixed with fp function creation (issue \#1298) 
+
 ## [2023-10-23]
 
 ### Added
diff --git a/l3kernel/l3fp-symbolic.dtx b/l3kernel/l3fp-symbolic.dtx
index 277ecfabf..31a4d0083 100644
--- a/l3kernel/l3fp-symbolic.dtx
+++ b/l3kernel/l3fp-symbolic.dtx
@@ -543,6 +543,7 @@
 %
 % \begin{macro}{\fp_clear_variable:n}
 % \begin{macro}{\@@_clear_variable:n}
+%   We need local undefining, so have to do it low-level.
 %    \begin{macrocode}
 \cs_new_protected:Npn \fp_clear_variable:n #1
   {
@@ -552,7 +553,7 @@
   }
 \cs_new_protected:Npn \@@_clear_variable:n #1
   {
-    \cs_undefine:c { l_@@_variable_#1_fp }
+    \cs_set_eq:cN { l_@@_variable_#1_fp } \tex_undefined:D
     \@@_variable_set_parsing:Nn \cs_set_eq:NN {#1}
   }
 %    \end{macrocode}
diff --git a/l3kernel/testfiles/m3fp-symbolic001.lvt b/l3kernel/testfiles/m3fp-symbolic001.lvt
index 9720e5ce1..f8cc16a31 100644
--- a/l3kernel/testfiles/m3fp-symbolic001.lvt
+++ b/l3kernel/testfiles/m3fp-symbolic001.lvt
@@ -84,4 +84,13 @@
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+\TEST { Intermixing~variables~and~functions }
+  {
+    \fp_new_variable:n { E }
+    \fp_new_function:n { PS }
+    \fp_set_variable:nn { E } { 2 }
+    \fp_set_function:nnn { PS } { E } { E**E }
+    \fp_show:n { E**2 + PS(3) }
+  }
+
 \END
diff --git a/l3kernel/testfiles/m3fp-symbolic001.tlg b/l3kernel/testfiles/m3fp-symbolic001.tlg
index f271b23aa..de34aa87b 100644
--- a/l3kernel/testfiles/m3fp-symbolic001.tlg
+++ b/l3kernel/testfiles/m3fp-symbolic001.tlg
@@ -141,3 +141,13 @@ contains 'Y' itself.
 <recently read> }
 l. ...  }
 ============================================================
+============================================================
+TEST 6: Intermixing variables and functions
+============================================================
+Defining \__fp_parse_word_E:N on line ...
+Defining \__fp_parse_word_PS:N on line ...
+Defining \__fp_parse_word__i:N on line ...
+> E**2+PS(3)=31.
+<recently read> }
+l. ...  }
+============================================================





More information about the latex3-commits mailing list.