Consider
\documentclass{article}
\usepackage{amsthm}
\newtheoremstyle{boldtheorem}
{}
{}
{\itshape}
{}
{}
{\itshape}
{}
{\bfseries}
{.}
{ }
{\thmnumber{#2}\ifx #3\relax\relax\thmname{ #1}\else\thmnote{ #3}\fi}
\theoremstyle{boldtheorem}
\newtheorem{theorem}{Theorem}[section]
\begin{document}
\end{document}
Compiling this with latex gives a Missing \begin{document} error on the line {.}.
Removing the . gives the error
! You can't use `macro parameter character #' in vertical mode.
<argument> ##
2
l.14 {\thmnumber{#2}
\ifx #3\relax\relax\thmname{ #1}\else\thmnote{ #3}\fi}
This is extracted from a larger preamble. I have removed all non-printable characters using the vim command :%s/[^[:print]]//g, but the error persists. Removing the .aux file does not seem to have an effect.
Any ideas?

\newtheoremstylemacro takes exactly 9 parameters. The line{.}is a tenth parameter... – Paul Gaborit Feb 12 '17 at 22:26\itshapeand\bfseries. – Henricus V. Feb 12 '17 at 22:31