You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When used on an undeclared hook, \UseOneTimeHook changes it to non-empty. That is, \HookIfEmptyTF would use the false branch. \UseHook doesn't have this problem.
The hook becomes non-empty because its \__hook_next <hook> is defined by \UseOneTimeHook. Is this expected behavior? If so my fix in #1515 is partially wrong.
\RequirePackage{latexbug} % <--should be always the first line (see CONTRIBUTING)!\documentclass{article}
\ExplSyntaxOn\cs_new_protected:Npn \test_hook:Nn #1#2
{
\iow_term:e {
[before]~ if~empty:~ \hook_if_empty:nTF {#2} T
{ F \iow_newline: [before]~ next~code:~\cs_meaning:c { __hook_next~#2 } }
}
\iow_term:n { [execute]~#1 {#2} }
#1 {#2}
\iow_term:e {
[after]~ if~empty:~ \hook_if_empty:nTF {#2} T
{ F \iow_newline: [after]~ next~code:~\cs_meaning:c { __hook_next~#2 } }
\iow_newline:
}
}
\iow_log:n { !~debug }
\test_hook:Nn \hook_use_once:n { undeclared~hook }
\test_hook:Nn \hook_use_once:n { package/amsmath/after } % issue #1513\test_hook:Nn \hook_use:n { undeclared~hook2 }
\ExplSyntaxOff\begin{document}
\end{document}
[before] if empty: T
[execute] \hook_use_once:n {undeclared hook}
[after] if empty: F
[after] next code: \long macro:#1#2#3#4#5#6#7#8#9->\__hook_use_once_clear:n {un
declared hook}
[before] if empty: T
[execute] \hook_use_once:n {package/amsmath/after}
[after] if empty: F
[after] next code: \long macro:->\__hook_use_once_clear:n {package/amsmath/afte
r}
[before] if empty: T
[execute] \hook_use:n {undeclared hook2}
[after] if empty: T
Brief outline of the bug
When used on an undeclared hook,
\UseOneTimeHook
changes it to non-empty. That is,\HookIfEmptyTF
would use the false branch.\UseHook
doesn't have this problem.The hook becomes non-empty because its
\__hook_next <hook>
is defined by\UseOneTimeHook
. Is this expected behavior? If so my fix in #1515 is partially wrong.Found when digging into #1513.
Minimal example showing the bug
Log file (required) and possibly PDF file
latex2e-UseOneTimeHook-changes-undeclared-hook-to-non-empty.log
The text was updated successfully, but these errors were encountered: