Applying Wilks' theorem to uniform distribution Suppose $X_i $ ~ $ U(0,b)$, for $i=1,2...n$  and we want to test the null hypothesis that $b=1$.
Assume $H_0$.  Then from Wilks' theorem, as $n \rightarrow \infty $, $ 2\ln(\frac{L_x(H_1)}{L_x(H_0)})$ should approximately follow a $\chi^2_1$ distribution.
But $\ln(\frac{L_x(H_1)}{L_x(H_0)})=-n\ln(x_{(n)})$, where $x_{(n)}$ is the maximum of all $x_{i}$.
When $n$ is large $2\ln(\frac{L_x(H_1)}{L_x(H_0)}) \approx 2n(1-x_{(n)})$
But this approximately follows a $\chi^2_2$ distribution.
Question: Am I wrong about the degrees of freedom, or does Wilks' theorem not apply here? (In which case, why?)
 A: From the Wikipedia page for Wilks' theorem:

The theorem no longer applies when any one of the estimated parameters is at its upper or lower limit: Wilks’ theorem assumes that the ‘true’ but unknown values of the estimated parameters lie within the interior of the supported parameter space. The likelihood maximum may no longer have the assumed ellipsoidal shape if the maximum value for the population likelihood function occurs at some boundary-value of one of the parameters, i.e. on an edge of the parameter space. In that event, the likelihood test will still be valid and optimal as guaranteed by the Neyman-Pearson lemma,[2] but the significance (the p-value) can not be reliably estimated using the chi-squared distribution with the number of degrees of freedom prescribed by Wilks.

In this case the estimated parameter $b$ is at its lower limit $x_{\left(n\right)}$, as the likelihood is zero for $b < x_{\left(n\right)}$.
Other proofs such as the asymptotic normality of the MLE also rely on the assumption that the true value of the parameter lies within the parameter space. So $\hat{b}$ is not asymptotically normal either.
A: Wilk's theorem assumes that the support of the distribution, i.e., the sample space, does not depend on the unknown parameter. Here, the parameter $b$ determines the width of the sample space so Wilk's theorem cannot be applied.
All the standard asymptotic tests associated with likelihood theory (Wald tests, likelihood ratio tests, score tests) make the same assumption.
To see why this assumption is so important, consider one of the most fundamental theorems used in likelihood theory, the fact that
$$E\left(\frac{\partial}{\partial \theta}\log f(X;\theta)\right)=0$$
where $f(x;\theta)$ is the density of $X$.
This theorem is proved by differentiating the left hand side of
$$
\int \exp(\log f(x;\theta)) dx = 1
$$
with respect to $\theta$ under the integral sign.
But now imagine what happens when the limits of the integral depend on $\theta$:
$$
\int_{a(\theta)}^{b(\theta)} \exp\left(\log f(x;\theta)\right) dx = 1
$$
Now the derivative of the left-hand-side is far more complex and the theorem is no longer true.
The same sort of problem occurs for all the other identities used in asympototic likelihod theory and for Wilk's theorem in particular.
A: Wilks' theorem does not apply here
Before getting to Wilks' theorem, one problem here (as with many questions about uniform distributions on this site) is that you have not taken account of the support of the uniform distribution in your mathematics, and this leads you to an incorrect form for the likelihood-ratio statistic.  You didn't specify your alternative hypothesis, but I'm going to assume it is $H_\text{A}:b>1$ (i.e., a one-sided test).  Given data $\mathbf{x} = (x_1,...,x_n)$ the likelihood function is:
$$L_\mathbf{x}(b) = \frac{\mathbb{I}(x_{(n)} \leqslant b)}{b^n} 
\quad \quad \quad \quad \quad \text{for all } b > 0,$$
so the maximised likelihood over any parameter subspace $\mathscr{B} \subseteq (0, \infty)$ is:
$$\begin{align}
\hat{L}_\mathbf{x}(\mathscr{B})
\equiv \sup_{b \in \mathscr{B}} L_\mathbf{x}(b) 
&= \sup_{b \in \mathscr{B}} \frac{\mathbb{I}(x_{(n)} \leqslant b)}{b^n} \\[12pt]
&= \begin{cases}
(\inf \mathscr{B})^{-n} & \text{if } \mathscr{B} \cap [x_{(n)}, \infty) \neq \varnothing, \\[6pt]
0 & \text{if } \mathscr{B} \cap [x_{(n)}, \infty) = \varnothing. \\[6pt]
\end{cases} \end{align}$$
(Note that this maximised likelihood is zero if there are no values $b \in \mathscr{B}$ with $b \geqslant x_{(n)}$.)  Consequently, using the hypotheses $H_0:b=1$ versus $H_\text{A}:b>1$ you get:
$$\begin{align}
\hat{L}_\mathbf{x}(H_\text{A})
&= \hat{L}_\mathbf{x}((1,\infty)) = 1, \\[12pt]
\hat{L}_\mathbf{x}(H_0)
&= \hat{L}_\mathbf{x}([1]) = \mathbb{I}(x_{(n)} \leqslant 1).
\end{align}$$
This gives the likelihood-ratio statistic:
$$\begin{align}
\Delta_{LR}
\equiv 2 \log \Bigg( \frac{\hat{L}_\mathbf{x}(H_\text{A})}{\hat{L}_\mathbf{x}(H_0)} \Bigg) 
&= 2 [ \hat{\ell}_\mathbf{x}(H_\text{A}) - \hat{\ell}_\mathbf{x}(H_0) ] \\[12pt]
&= 2 [ 0 - \log \mathbb{I}(x_{(n)} \leqslant 1)] \\[12pt]
&= \begin{cases}
0 & & \text{if } x_{(n)} \leqslant 1, \\[6pt]
\infty & & \text{if } x_{(n)} > 1. \\[6pt]
\end{cases}
\end{align}$$
This statistic has a distribution concentrated on two possible values, so it does not obey the approximate chi-squared distribution.  The reason that Wilks' theorem does not apply to this case is that the maximising parameter values for each maximised likelihood value occur on the boundary of the parameter range rather than the interior of the parameter range.
