% test file provided by Felix Neubauer <felix.neubauer@gmx.net>
\listfiles
\documentclass{article}
\usepackage{nameref}
\usepackage{varioref}
\usepackage{hyperref}

\begin{document}
\section{Blah}
\label{sec:blah}

In section~\vref{sec:bar}% test a

Figure~\vref{fig:fig}% test b

\begin{figure}[htbp]
  Figure
  \caption{A Figure}
  \label{fig:fig}
\end{figure}

Figure~\vref{fig:fig}% test c


\section{Bar}
\label{sec:bar}

Figure~\vref{fig:fig}% test d

\clearpage
\section{Foo}
\label{sec:foo}

Sctions~\vrefrange{sec:blah}{sec:bar}% test e
\end{document}

With nameref and hyperref loaded this file should be run one in
\batchmode to produce a working .aux file which yields the
following
result:

 * test a: produces wrong output: it should be

   In section 2

   but results in

   In section 2 on page 1

 * test b: the same as with test a, but with Figure 1

 * test c: fails on the first run without (correct) *.aux file with

+-------------------------------------------------------
| ! Argument of \@fifthoffive has an extra }.
| <inserted text>
|                 \par
| l.21 Figure~\vref{fig:fig}
|                           % test c
+-------------------------------------------------------

  Procduces correct output after continuing with batchmode and 2
reruns

 * test d: again produces wrong output:

   Figure 1 on page 1

   inestead of

   Figure 1

 * test e: this produces

   Sections 1 to 2 on pages 1-1

   instead of

   Sections 1 to 2 on the preceeding page

> * varioref contains:
>   \@ifundefined{r@#2}{\@namedef{r@#2}{{??}{??}}{}%
>   You are using {}{\thepage} instead of the question marks, why?
>

Ooops, it should have been

\def\vref@pagenum#1#2{%
  \@ifundefined{r@#2}{\@namedef{r@#2}{{??}{??}{}{}{}}}{}%
  \edef#1{\hypergetpageref{#2}}%
}

Greetings
  Felix
--
Felix Neubauer, felix.neubauer@gmx.net
