$\newcommand{\ld}{\mathcal{L}}\newcommand{\adj}[1]{#1^\dagger}\newcommand{\dc}[1]{\overline{#1}}\newcommand{\Psi}{\varPsi}\newcommand{\dd}{\mathrm{d}}$Take a typical Lagrangian density defined over Minkowski spacetime with metric $\eta=\operatorname{diag}(-1,1,1,1)$, say the scalar field one \begin{equation} \ld= -\frac12\partial^\mu\phi\partial_\mu\phi-\frac12 m^2\phi^2. \end{equation} In order to switch to an Euclidean field theory, I have to perform a Wick rotation. I imagine that a rigorous approach to the "rotation of the integration domain" goes like this: consider, firstly, the closed path $\Gamma_R$ given by the maps
- $t\mapsto -R+2Rt$,
- $t\mapsto Re^{i\frac{\pi}{2}t}$,
- $t\mapsto iR-2iRt$,
- $t\mapsto -iRe^{-i\frac{\pi}{2}t}$,
in succession, all with $t\in[0,1]$. Now I have to consider the analytic continuation of $\ld$ as a function of $x^0$ into the complex plane: assuming that the involved function are analytic where needed, by Cauchy's theorem the integral in $x^0$ along $\Gamma_R$ is zero for every $R$. Moreover, for $R\to+\infty$, assuming that the fields fall off at infinity rapidly enough for the integral over the two arcs to go to zero, I obtain that \begin{equation} \int_{-\infty}^{+\infty}\ld\,\dd x^0= -\int_{i\infty}^{-i\infty}\ld\,\dd x^0= \int_{-i\infty}^{i\infty}\ld\,\dd x^0 \end{equation} and then renaming $x^0=ix^4$ \begin{equation} \int_{-\infty}^{+\infty}\ld(x^0,\dotsc)\,\dd x^0= i\int_{-\infty}^{+\infty}\ld(ix^4,\dotsc)\,\dd x^4. \end{equation} Therefore, in the path integral weight $e^{iS}$, the $i$ factor together with the one I get from the Wick rotation gives a $-1$, so $e^{iS}$ becomes $e^{S'}$ with \begin{equation} S'= \frac12\int_{\mathbb{R}^4}(\partial^i\phi\partial_i\phi+m^2\phi^2)\,\dd x^1\,\dd x^2\,\dd x^3\,\dd x^4 \end{equation} that is the opposite of what I wanted, that is an exponentially decaying function $e^{-S}$ with $S$ a positive definite quadratic form in the fields.
If I close, instead, the integration contour in the other two quadrants of the complex plane, I obtain \begin{equation} \int_{-\infty}^{+\infty}\ld\,\dd x^0= -\int_{-i\infty}^{i\infty}\ld\,\dd x^0 \end{equation} and this minus sign gets me what I want in the end.
I feel that the first procedure should have some kind of obstruction. After all, if both are possible, that means that $\ld$ is an entire function of $x^0$, and since we assume that the fields (and their derivatives) go to zero when $\lvert x^0\rvert\to +\infty$, as required by the above calculations to work, by Liouville's theorem $\ld=0$, if I'm correct.
Now, assuming that the above procedures are correct: does $\ld$ have some singularities in the complex plane that prevent from going both ways? If so, can I determine them? Or is there some error in my "proof" of the Wick rotation?