Weak convergence + pointwise convergence on dense subspace of $L^2$ Let $H$ be a dense subspace of $L^2(X,\mu)$ ($X$ being a separable and complete metric space with finite measure $\mu$) and $(f_n)_{n\in\mathbb N}$ be a sequence in $H$ that converges to $f\in L^2(X,\mu)$ in the following sense:
$$
\langle f_n - f, h \rangle_{L^2} \xrightarrow{n\to\infty} 0
\quad
\text{for all } h\in H.
$$
In addition, let $f_n$ converge pointwise $\mu$-almost everywhere to some function $g$, i.e. $f_n(x)\xrightarrow{n\to\infty} g(x)$ for $\mu$-almost every $x\in X$.
I need to show that $f$ and $g$ agree $\mu$-almost everywhere, in other words $f_n(x)\xrightarrow{n\to\infty} f(x)$ pointwise for $\mu$-almost every $x\in X$.
I have been struggling to prove this (and also to find counterexamples), but so far I cannot find the right analytical tools. Any help will be very appreciated!
Remark: I know very little about the $f_n$, there may be no upper bound on their norm etc.
Remark: The background is that I am trying to prove a convergence result for conditional mean embeddings in reproducing kernel Hilbert spaces (this is not an homework exercise).

Another counterexample for $L^2(-\pi,\pi)$:


Lemma If $Z$ is an inner product space, $x_1,\dots,x_n\in Z$ are independent, and $c_1,\dots,c_n$ are scalars then there exists $x\in Z$ with $\langle x,x_j\rangle=c_j$ for $j=1,\dots, n$.


Proof: By linearity (and symmetry) we can assume $c_1=\dots=c_{n-1}=0$, $c_n=1$. Let $X$ be the span of $x_1,\dots,x_n$ and let $Y$ be the span of $x_1,\dots,x_{n-1}$. Since $Y$ is a proper subspace of $X$ there exists $x\in X$ with $x\ne0$ but $\langle x,x_j\rangle=0$ for $j=1,\dots,n-1$.  Now $x\ne0$ implies that $\langle x, x_n\rangle\ne0$.


Cor. Given $\delta>0$, a positive integer $N$ and complex numbers $c_{-N},\dots,c_N$ there exists $g\in  L^2(-\pi,\pi)$ such that $g$ vanishes off $(0,\delta)$ and $\hat g(k)=c_k$, $-N\le k\le N$.


Now let $F$ be any non-zero element of $L^2(-\pi,\pi)$, and choose $g_n$ so $g_n$ vanishes off $(0,1/n)$ and $$\hat g(k)=-\hat F(k),\quad(|k|\le n).$$Let $$f_n=F+g_n.$$Then $f_n\to F$ almost everywhere, but $$\lim_n\hat f_n(k)=0\quad(k\in\Bbb Z),$$hence $$\lim_n\langle f_n, h\rangle=0$$for every trigonometric polynomial $h$.
