MacTeX 2020: error with report + hyperref + mathbf in chapter

One step forward two steps back...

ltfssdcl.dtx in the format has:

% \changes{v3.0u}{2020/03/19}{fix for (gnats/3357)}
%    \begin{macrocode}
 \expandafter#1\ifx\math@bgroup\bgroup{#4}\else#4\fi

latex/3357 has an interesting discusssion showing this is a tricky area....

https://www.latex-project.org/cgi-bin/ltxbugs2html?category=LaTeX&responsible=anyone&state=anything&keyword=&pr=latex%2F3357&search=

However I think adding two more \expandafter is the correct fix here

\documentclass{report}
\usepackage{hyperref}

\makeatletter
\def\document@select@group#1#2#3#4{%
 \ifx\math@bgroup\bgroup\else\relax\expandafter\@firstofone\fi
 {%
 \ifmmode
   \ifnum\csname c@mv@\math@version\endcsname<\e@mathgroup@top
     \begingroup
       \escapechar\m@ne
       \getanddefine@fonts{\csname c@mv@\math@version\endcsname}#3%
       \globaldefs\@ne  \math@fonts
     \endgroup
     \expandafter\extract@alph@from@version
         \csname mv@\math@version\expandafter\endcsname
         \expandafter{\number\csname
                       c@mv@\math@version\endcsname}%
          #1%
     \global\advance\csname c@mv@\math@version\endcsname\@ne
   \else
     \let#1\relax
     \@latex@error{Too many math alphabets used
                   in version \math@version}%
        \@eha
  \fi
 \else \expandafter\expandafter\expandafter\non@alpherr\fi
%    \end{macrocode}
%    If the legacy interface is used, e.g., \verb=$\sf -1$= the math
%    alphabet \verb=#1= does not take an argument so we better do not
%    surround \verb=#4= with braces, because then we get
%    \verb={\relax}= into the formula and introduce an extra Ord
%    atom. The two different cases can be distinguished by looking at
%    the current value of \cs{math@bgroup}.
% \changes{v3.0u}{2020/03/19}{fix for (gnats/3357)}
%    \begin{macrocode}
 \expandafter#1\ifx\math@bgroup\bgroup{#4}\else#4\fi
 }%
}
\makeatother
\begin{document}


\chapter{This raises an error: \(\mathbf{x}=y\)}

test

\chapter{Using this instead works: \({\bf x}=y\)}

test

\end{document}

I will raise an issue at the latex github

enter image description here


You can get away with the error by providing a substitution for \mathbf:

\documentclass{report}
\usepackage{hyperref}

\makeatletter
\pdfstringdefDisableCommands{%
  \let\mathbf\@firstofone
}
\makeatother

\begin{document}

\chapter{This works \(\mathbf{x}=y\)}

test

\end{document}

On the other hand, using math in bookmarks won't work anyhow, so maybe it's preferable to use \texorpdfstring:

\documentclass{report}
\usepackage{hyperref}

\begin{document}

\chapter{This works better \texorpdfstring{\(\mathbf{x}=y\)}{x=y}}

test

\end{document}