I want to patch \addcontentsline command for changing \thepage to \thechapter--\thepage. However I found that things went wrong when I used expl block:
\documentclass{book}
\usepackage{etoolbox}
% \usepackage{hyperref}
\ExplSyntaxOn
\patchcmd{\addcontentsline}{\thepage}{\thechapter--\thepage}{\typeout{toc~succeed}}{\typeout{toc~fail}}
\ExplSyntaxOff
% \patchcmd{\addcontentsline}{\thepage}{\thechapter--\thepage}{\typeout{toc succeed}}{\typeout{toc fail}}
\begin{document}
\tableofcontents
\section{one}
\chapter{text}
\section{two}
\end{document}
If I didn't load hyperref package, the patch can be done both inside and outside expl block: terminal types tocsucceed;
If I load hyperref package, the patch can't be done inside expl block: terminal types tocfail, but can be done outside expl block.
Why would this happen?

bookmark\temp@online:\MessageBreakin hyperref-defined\addcontentsline, so it breaks\patchcmd? Also, if I want to patch this in aexplpackage, I have to use\ExplSyntaxOffto exit expl environment and finish it? – Syvshc May 14 '22 at 03:00\patchcmdin expl3, even a simple linebreak? So can I say that if I want to patch a command from latex2e, I should work under 2e environment? – Syvshc May 14 '22 at 03:57