From maechler at stat.math.ethz.ch  Tue Apr  3 19:14:30 2018
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Tue, 3 Apr 2018 19:14:30 +0200
Subject: [Rd] names lost in functions from packages installed by R-devel
 r74500
In-Reply-To: <23235.38822.497055.259303@stat.math.ethz.ch>
References: <cde5f0e1-40f5-9b58-38c6-6bcbad22bcc5@umontpellier.fr>
 <23235.38822.497055.259303@stat.math.ethz.ch>
Message-ID: <23235.46710.747326.101066@stat.math.ethz.ch>

>>>>> Martin Maechler <maechler at stat.math.ethz.ch>
>>>>>     on Tue, 3 Apr 2018 17:03:02 +0200 writes:

>>>>> Francois Rousset <francois.rousset at umontpellier.fr>
>>>>>     on Tue, 3 Apr 2018 16:38:42 +0200 writes:

    >> Dear list members,
    >> If I install with R-devel r74500 on Windows (sessionInfo below) the 
    >> attached 'bugdemo' package with the single function

    >> foo <- function() {
    >> ? named <- c("bar"=TRUE)
    >> ? print(named)
    >> ? return(named)
    >> }

    >> then run

    >>> bugdemo::foo()
    >> [1] TRUE
    >> [1] TRUE

    >> The "bar" name is lost. It is not lost when I define foo in the R 
    >> session instead of using its packaged version.

    >> To reproduce:

    >> =======================================

    >> install.packages("bugdemo_0.1.1.tar.gz",type="source",repos=NULL)

    >> bugdemo::foo()



    >> =======================================

    >> I also tested whether this was a problem with the "R CMD build" step or 
    >> the "install.packages()" step by building with R 3.4.4 and installing 
    >> with R-devel, and reciprocally, and the problem appears to be in the 
    >> install step of R-devel.

    > Confirmed.

    > It is a bug somewhere between the byte compiler and
    > (de)serialization .. really beyond my own expertise:

    > If you install  without byte compilation *),  foo() behaves as
    > expected, i.e., does not "lose" the names.

    > On the other hand, as you mention, if you define foo in the
    > globalenv, and call it, the JIT kicks in pretty quickly and you
    > can see that 'foo' is byte compiled as well, but it still does not break.

    > This is pretty important, so thank you very much for the nice
    > reproducible report!

    > Martin Maechler
    > ETH Zurich

    > ---
    > *) R-devel CMD INSTALL --no-byte-compile -l ...

This has been fixed now, both in R-devel (svn rev 74511)
and in R 3.5.0 alpha (r 74513).

I was wrong in that this was related to (de)serialization.
Rather I had forgotten that JIT (just in time) compilation and
explicit compilation may differ in their results.

Thank you again for the report!

Martin Maechler
ETH Zurich



    >> =============

    >>> sessionInfo()
    >> R Under development (unstable) (2018-03-31 r74500)

    [ ........... ]



[Rd] names lost in functions from packages installed by R-devel r74500
Martin Maechler