[latex3-commits] [latex3/latex3] main: Avoid "Inconsistent local/global assignment" errors in \cctab_const:Nn (aefb9f400)

github at latex-project.org github at latex-project.org
Wed Mar 20 10:46:44 CET 2024


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

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

commit aefb9f400d68d510073aea8d0b1425e6efdab2ca
Author: Yukai Chou <muzimuzhi at gmail.com>
Date:   Wed Mar 20 02:27:34 2024 +0800

    Avoid "Inconsistent local/global assignment" errors in \cctab_const:Nn
    
    See #1508.


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

aefb9f400d68d510073aea8d0b1425e6efdab2ca
 l3kernel/CHANGELOG.md                    |  3 +++
 l3kernel/l3cctab.dtx                     |  6 ++++-
 l3kernel/testfiles/m3cctab002.luatex.tlg | 38 +++++++-------------------
 l3kernel/testfiles/m3cctab002.lvt        | 10 ++++---
 l3kernel/testfiles/m3cctab002.tlg        | 46 +++++---------------------------
 l3kernel/testfiles/m3cctab002.xetex.tlg  | 46 +++++---------------------------
 6 files changed, 38 insertions(+), 111 deletions(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 9c8c4d506..abc49b9a9 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -7,6 +7,9 @@ this project uses date-based 'snapshot' version identifiers.
 
 ## [Unreleased]
 
+### Fixed
+- Global assignment to constant in `\cctab_const:Nn` (issue \#1508)
+
 ## [2024-03-14]
 
 ### Added
diff --git a/l3kernel/l3cctab.dtx b/l3kernel/l3cctab.dtx
index 5cdaa3dc9..38482e296 100644
--- a/l3kernel/l3cctab.dtx
+++ b/l3kernel/l3cctab.dtx
@@ -797,12 +797,16 @@
 %
 % \begin{macro}{\cctab_const:Nn,\cctab_const:cn}
 %  Creates a new \meta{cctab~var} then sets it with the current and
-%  user-supplied codes.
+%  user-supplied codes. The \cs{debug_suspend:} and \cs{debug_resume:}
+%  functions prevent \cs{cctab_new:N} and \cs{cctab_gset:Nn} from
+%  raising errors on global assignment to constant.
 %    \begin{macrocode}
 \cs_new_protected:Npn \cctab_const:Nn #1#2
   {
+    \debug_suspend:
     \cctab_new:N #1
     \cctab_gset:Nn #1 {#2}
+    \debug_resume:
   }
 \cs_generate_variant:Nn \cctab_const:Nn { c }
 %    \end{macrocode}
diff --git a/l3kernel/testfiles/m3cctab002.luatex.tlg b/l3kernel/testfiles/m3cctab002.luatex.tlg
index 99ac514f4..3facfd5d1 100644
--- a/l3kernel/testfiles/m3cctab002.luatex.tlg
+++ b/l3kernel/testfiles/m3cctab002.luatex.tlg
@@ -46,7 +46,13 @@ TEST 5: Nested groups
 \g__cctab_internaliii_cctab=\catcodetable...
 ============================================================
 ============================================================
-TEST 6: Wrong scoping
+TEST 6: Scoping
+============================================================
+\g_new_cctab=\catcodetable...
+\c_const_cctab=\catcodetable...
+============================================================
+============================================================
+TEST 7: Wrong scoping
 ============================================================
 ! LaTeX Error: Inconsistent local/global assignment
 For immediate help type H <return>.
@@ -55,7 +61,6 @@ l. ...  }
 This is a coding error.
 Global assignment to a constant variable '\c_new_cctab'.
 \c_new_cctab=\catcodetable...
-\g_new_cctab=\catcodetable...
 ! LaTeX Error: Inconsistent local/global assignment
 For immediate help type H <return>.
  ...                                              
@@ -68,19 +73,6 @@ For immediate help type H <return>.
  ...                                              
 l. ...  }
 This is a coding error.
-Global assignment to a constant variable '\c_const_cctab'.
-\c_const_cctab=\catcodetable...
-! LaTeX Error: Inconsistent local/global assignment
-For immediate help type H <return>.
- ...                                              
-l. ...  }
-This is a coding error.
-Global assignment to a constant variable '\c_const_cctab'.
-! LaTeX Error: Inconsistent local/global assignment
-For immediate help type H <return>.
- ...                                              
-l. ...  }
-This is a coding error.
 Constant assignment to a global variable '\g_const_cctab'.
 \g_const_cctab=\catcodetable...
 ! LaTeX Error: Inconsistent local/global assignment
@@ -89,24 +81,12 @@ For immediate help type H <return>.
 l. ...  }
 This is a coding error.
 Constant assignment to a local variable '\l_const_cctab'.
-! LaTeX Error: Inconsistent local/global assignment
-For immediate help type H <return>.
- ...                                              
-l. ...  }
-This is a coding error.
-Global assignment to a local variable '\l_const_cctab'.
 \l_const_cctab=\catcodetable...
 ! LaTeX Error: Inconsistent local/global assignment
 For immediate help type H <return>.
  ...                                              
 l. ...  }
 This is a coding error.
-Global assignment to a local variable '\l_const_cctab'.
-! LaTeX Error: Inconsistent local/global assignment
-For immediate help type H <return>.
- ...                                              
-l. ...  }
-This is a coding error.
 Global assignment to a constant variable '\c_const_cctab'.
 ! LaTeX Error: Inconsistent local/global assignment
 For immediate help type H <return>.
@@ -116,7 +96,7 @@ This is a coding error.
 Global assignment to a local variable '\l_const_cctab'.
 ============================================================
 ============================================================
-TEST 7: Wrong nesting with groups: expect three errors and many TRUE
+TEST 8: Wrong nesting with groups: expect three errors and many TRUE
 ============================================================
 TRUE
 ! LaTeX Error: \cctab_end: occurred in a higher group level than the matching \cctab_begin:N.
@@ -150,7 +130,7 @@ TRUE
 TRUE
 ============================================================
 ============================================================
-TEST 8: catcode of a specific character
+TEST 9: catcode of a specific character
 ============================================================
 8,12,0,10,12
 [\directlua]:1: incorrect character value -1 for tex.getcatcode()
diff --git a/l3kernel/testfiles/m3cctab002.lvt b/l3kernel/testfiles/m3cctab002.lvt
index 116a66da0..dc58e8456 100644
--- a/l3kernel/testfiles/m3cctab002.lvt
+++ b/l3kernel/testfiles/m3cctab002.lvt
@@ -51,16 +51,20 @@
     \group_end:
   }
 
+\TEST { Scoping }
+  {
+    \cctab_new:N \g_new_cctab
+    \cctab_const:Nn \c_const_cctab { }
+    \cctab_gset:Nn \g_new_cctab { }
+  }
+
 \TEST { Wrong~scoping }
   {
     \cctab_new:N \c_new_cctab
-    \cctab_new:N \g_new_cctab
     \cctab_new:N \l_new_cctab
-    \cctab_const:Nn \c_const_cctab { }
     \cctab_const:Nn \g_const_cctab { }
     \cctab_const:Nn \l_const_cctab { }
     \cctab_gset:Nn \c_const_cctab { }
-    \cctab_gset:Nn \g_const_cctab { }
     \cctab_gset:Nn \l_const_cctab { }
   }
 
diff --git a/l3kernel/testfiles/m3cctab002.tlg b/l3kernel/testfiles/m3cctab002.tlg
index 33fe55ebd..a5b2a0056 100644
--- a/l3kernel/testfiles/m3cctab002.tlg
+++ b/l3kernel/testfiles/m3cctab002.tlg
@@ -39,7 +39,11 @@ TEST 5: Nested groups
 ============================================================
 ============================================================
 ============================================================
-TEST 6: Wrong scoping
+TEST 6: Scoping
+============================================================
+============================================================
+============================================================
+TEST 7: Wrong scoping
 ============================================================
 ! LaTeX Error: Inconsistent local/global assignment
 For immediate help type H <return>.
@@ -70,24 +74,6 @@ For immediate help type H <return>.
  ...                                              
 l. ...  }
 This is a coding error.
-Global assignment to a constant variable '\c_const_cctab'.
-! LaTeX Error: Inconsistent local/global assignment
-For immediate help type H <return>.
- ...                                              
-l. ...  }
-This is a coding error.
-Global assignment to a constant variable '\c_const_cctab'.
-! LaTeX Error: Inconsistent local/global assignment
-For immediate help type H <return>.
- ...                                              
-l. ...  }
-This is a coding error.
-Global assignment to a constant variable '\c_const_cctab'.
-! LaTeX Error: Inconsistent local/global assignment
-For immediate help type H <return>.
- ...                                              
-l. ...  }
-This is a coding error.
 Constant assignment to a global variable '\g_const_cctab'.
 ! LaTeX Error: Inconsistent local/global assignment
 For immediate help type H <return>.
@@ -100,24 +86,6 @@ For immediate help type H <return>.
  ...                                              
 l. ...  }
 This is a coding error.
-Global assignment to a local variable '\l_const_cctab'.
-! LaTeX Error: Inconsistent local/global assignment
-For immediate help type H <return>.
- ...                                              
-l. ...  }
-This is a coding error.
-Global assignment to a local variable '\l_const_cctab'.
-! LaTeX Error: Inconsistent local/global assignment
-For immediate help type H <return>.
- ...                                              
-l. ...  }
-This is a coding error.
-Global assignment to a local variable '\l_const_cctab'.
-! LaTeX Error: Inconsistent local/global assignment
-For immediate help type H <return>.
- ...                                              
-l. ...  }
-This is a coding error.
 Global assignment to a constant variable '\c_const_cctab'.
 ! LaTeX Error: Inconsistent local/global assignment
 For immediate help type H <return>.
@@ -127,7 +95,7 @@ This is a coding error.
 Global assignment to a local variable '\l_const_cctab'.
 ============================================================
 ============================================================
-TEST 7: Wrong nesting with groups: expect three errors and many TRUE
+TEST 8: Wrong nesting with groups: expect three errors and many TRUE
 ============================================================
 TRUE
 ! LaTeX Error: \cctab_end: occurred in a higher group level than the matching \cctab_begin:N.
@@ -161,7 +129,7 @@ TRUE
 TRUE
 ============================================================
 ============================================================
-TEST 8: catcode of a specific character
+TEST 9: catcode of a specific character
 ============================================================
 8,12,0,10,12
 ! Use of \??? doesn't match its definition.
diff --git a/l3kernel/testfiles/m3cctab002.xetex.tlg b/l3kernel/testfiles/m3cctab002.xetex.tlg
index edb0c7d33..0374668fa 100644
--- a/l3kernel/testfiles/m3cctab002.xetex.tlg
+++ b/l3kernel/testfiles/m3cctab002.xetex.tlg
@@ -39,7 +39,11 @@ TEST 5: Nested groups
 ============================================================
 ============================================================
 ============================================================
-TEST 6: Wrong scoping
+TEST 6: Scoping
+============================================================
+============================================================
+============================================================
+TEST 7: Wrong scoping
 ============================================================
 ! LaTeX Error: Inconsistent local/global assignment
 For immediate help type H <return>.
@@ -70,24 +74,6 @@ For immediate help type H <return>.
  ...                                              
 l. ...  }
 This is a coding error.
-Global assignment to a constant variable '\c_const_cctab'.
-! LaTeX Error: Inconsistent local/global assignment
-For immediate help type H <return>.
- ...                                              
-l. ...  }
-This is a coding error.
-Global assignment to a constant variable '\c_const_cctab'.
-! LaTeX Error: Inconsistent local/global assignment
-For immediate help type H <return>.
- ...                                              
-l. ...  }
-This is a coding error.
-Global assignment to a constant variable '\c_const_cctab'.
-! LaTeX Error: Inconsistent local/global assignment
-For immediate help type H <return>.
- ...                                              
-l. ...  }
-This is a coding error.
 Constant assignment to a global variable '\g_const_cctab'.
 ! LaTeX Error: Inconsistent local/global assignment
 For immediate help type H <return>.
@@ -100,24 +86,6 @@ For immediate help type H <return>.
  ...                                              
 l. ...  }
 This is a coding error.
-Global assignment to a local variable '\l_const_cctab'.
-! LaTeX Error: Inconsistent local/global assignment
-For immediate help type H <return>.
- ...                                              
-l. ...  }
-This is a coding error.
-Global assignment to a local variable '\l_const_cctab'.
-! LaTeX Error: Inconsistent local/global assignment
-For immediate help type H <return>.
- ...                                              
-l. ...  }
-This is a coding error.
-Global assignment to a local variable '\l_const_cctab'.
-! LaTeX Error: Inconsistent local/global assignment
-For immediate help type H <return>.
- ...                                              
-l. ...  }
-This is a coding error.
 Global assignment to a constant variable '\c_const_cctab'.
 ! LaTeX Error: Inconsistent local/global assignment
 For immediate help type H <return>.
@@ -127,7 +95,7 @@ This is a coding error.
 Global assignment to a local variable '\l_const_cctab'.
 ============================================================
 ============================================================
-TEST 7: Wrong nesting with groups: expect three errors and many TRUE
+TEST 8: Wrong nesting with groups: expect three errors and many TRUE
 ============================================================
 TRUE
 ! LaTeX Error: \cctab_end: occurred in a higher group level than the matching \cctab_begin:N.
@@ -161,7 +129,7 @@ TRUE
 TRUE
 ============================================================
 ============================================================
-TEST 8: catcode of a specific character
+TEST 9: catcode of a specific character
 ============================================================
 8,12,0,10,12
 ! Use of \??? doesn't match its definition.





More information about the latex3-commits mailing list.