Skip to content

CSName parameters should (sometimes?) expand protected macros #1006

Description

@dginev

Minimal latex example:

\documentclass{article}
\usepackage{etoolbox}
\begin{document}

\expandafter\def\csname test-def\endcsname{prints the word def}
\expandafter\def\csname test-robust\endcsname{prints the word robust}

\def\mydef{def}
\newrobustcmd\myrobust{robust}

\csname test-\mydef\expandafter\endcsname

\csname test-\myrobust\expandafter\endcsname

\end{document}

The PDF result is:

prints the word def
prints the word robust

The latexml result is correct for the def case, but fails with an error in the robust case:

Error:unexpected:\myrobust The control sequence \myrobust should not appear between \csname and \endcsname

Tracing this down, I landed in State::lookupExpandable where this peculiar line is responsible for the discrepancy:

    && ($toplevel || !$$defn{isProtected})) { # is this the right logic here? don't expand unless digesting?

Simply commenting out that condition gets the example working, and fixes the general issue of using robust macros in expandable contexts.

However, running a make test shows failures in various places, so I'm assuming the real adjustment is more subtle.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions