I have a simple TeX file like this
\documentclass{article}
\begin{document}
\def\printcsnameof #1{
\escapechar=-1
\string #1
}
\printcsnameof \test
\end{document}
When I compile it the first time, it works well and print test on the page.
However, from the second run, it raises the error
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
->\errmessage LaTeX Error: Missing \protect \begin {document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help@err@
l.2 g
def @abspage@last{1}
?
What is going on?