Skip to content

Commit

Permalink
Avoid "Inconsistent local/global assignment" errors in \cctab_const:Nn
Browse files Browse the repository at this point in the history
  • Loading branch information
muzimuzhi committed Mar 19, 2024
1 parent 35b15d8 commit 00272dc
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 111 deletions.
3 changes: 3 additions & 0 deletions l3kernel/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion l3kernel/l3cctab.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -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 inconsistent local/global assignment.
% \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}
Expand Down
38 changes: 9 additions & 29 deletions l3kernel/testfiles/m3cctab002.luatex.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -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>.
Expand All @@ -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>.
...
Expand All @@ -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
Expand All @@ -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>.
Expand All @@ -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.
Expand Down Expand Up @@ -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()
Expand Down
10 changes: 7 additions & 3 deletions l3kernel/testfiles/m3cctab002.lvt
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
}

Expand Down
46 changes: 7 additions & 39 deletions l3kernel/testfiles/m3cctab002.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -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>.
Expand Down Expand Up @@ -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>.
Expand All @@ -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>.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
46 changes: 7 additions & 39 deletions l3kernel/testfiles/m3cctab002.xetex.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -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>.
Expand Down Expand Up @@ -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>.
Expand All @@ -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>.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 00272dc

Please sign in to comment.