In this answer, @egreg provided a modified \pmod with a starred variant. However, after some recent update to the TeX distribution this modification no longer works (the last time I used this command in my document seems to be in May). Below is a MWE.
\documentclass{article}
\makeatletter
\let@@pmod\pmod
\DeclareRobustCommand{\pmod}{@ifstar@pmods@@pmod}
\def@pmods#1{\mkern4mu({\operator@font mod}\mkern 6mu#1)}
\makeatother
\begin{document}
( x^2 \equiv 1 \pmod{4} )
\end{document}
There is no error, but the compilation never stops. Below is the log file.
This is XeTeX, Version 3.141592653-2.6-0.999994 (TeX Live 2022) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
(/modified-pmod-test.tex
LaTeX2e <2022-06-01> patch level 5
L3 programming layer <2022-08-05> (/usr/local/texlive/2022/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/size10.clo)) (/usr/local/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-xetex.def) (./modified-pmod-test.aux) (/usr/local/texlive/2022/texmf-dist/tex/latex/base/ts1cmr.fd)
\NewCommandCopy\@@pmod\pmodinstead of\let– Ulrike Fischer Aug 08 '22 at 20:48