Hello.
This question refers to XeLaTeX and not XeTeX which gives correct
results (see below).
The following code shows an incorrect \lastkern value during the \ifnum
test: the first line shows abnormal behaviour while the second, thanks
to the \relax, gives the expected result.
%%%%%%%%%%%%%% CODE %%%%%%%%%%%%%%
\documentclass{article}
\begin{document}
Should be An: \kern2019sp A\ifnum\lastkern=2019 y\else n\fi\par
Should be An: \kern2019sp A\relax\ifnum\lastkern=2019 y\else n\fi
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
With XeTeX, the following code gives the expected results: there is
probably something wrong with XeLaTeX, but I cannot find what.
%%%%%%%%%%%%%% CODE %%%%%%%%%%%%%%
Should be An: \kern2019sp A\ifnum\lastkern=2019 y\else n\fi\par
Should be An: \kern2019sp A\relax\ifnum\lastkern=2019 y\else n\fi
\bye
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Best.
Christian Tellechea