The pgffor has changed to handle FPU types, but since then direct usage of registers fails. The MWE has to be processed with pdfLaTeX.
\documentclass{article}
\usepackage{pgffor}
\begin{document}
\pdfximage{example-image.pdf}
\begingroup
\tracingall
\foreach \n in {1,...,\pdflastximagepages} {}
\endgroup
\end{document}
Workaround: Prefix registers with \the.
Other workaround: Restore the old
\foreachbehaviour.The offending commit is this one: https://sourceforge.net/p/pgf/git/ci/acdfa1450bd2beda4d6865bb2717e4d6f628c875/