Consider the following three minimal examples. I do not understand why the first doesn't work while the second and third is fine. Can anyone tell me? Hyperref seems to have problems when \thethm is pointing to an undefined reference. Please don't ask why pointing to an undefined reference makes sense. I do have a good reason for that but it has nothing to do with this question.
First example (produces strange error):
\documentclass{article}
\usepackage[thmmarks,hyperref]{ntheorem}
\usepackage{hyperref}
\newtheorem{thm}{Theorem}
\newtheorem{prop}[thm]{Proposition}
\begin{document}
\begingroup
\def\thethm{\ref{a}'}
\addtocounter{thm}{-1}
\begin{prop}
yyy
\label{test}
\end{prop}
\endgroup
\end{document}
Second example, hyperref removed, otherwise identical code (works fine):
\documentclass{article}
\usepackage[thmmarks]{ntheorem}
\newtheorem{thm}{Theorem}
\newtheorem{prop}[thm]{Proposition}
\begin{document}
\begingroup
\def\thethm{\ref{a}'}
\addtocounter{thm}{-1}
\begin{prop}
yyy
\label{test}
\end{prop}
\endgroup
\end{document}
Third example, code as in the first example but \thethm is changed (also works well):
\documentclass{article}
\usepackage[thmmarks,hyperref]{ntheorem}
\usepackage{hyperref}
\newtheorem{thm}{Theorem}
\newtheorem{prop}[thm]{Proposition}
\begin{document}
\begingroup
\def\thethm{1'}
\addtocounter{thm}{-1}
\begin{prop}
yyy
\label{test}
\end{prop}
\endgroup
\end{document}
