From mtmorg@n@bioc @ending from gm@il@com  Fri Jan  4 01:13:02 2019
From: mtmorg@n@bioc @ending from gm@il@com (Martin Morgan)
Date: Fri, 4 Jan 2019 00:13:02 +0000
Subject: [Rd] Compiler + stopifnot bug
In-Reply-To: <dce3cbe4-ee06-ec13-d307-5230e98df7c8@gmail.com>
References: <CALEXWq2CneLqRqaD5H4_-qQEzB3LjhSwoqc=Mg3f9WeHAirmXg@mail.gmail.com>
 <ffedc6fa-2f6c-21f3-b29a-8e1f0e3fac89@gmail.com>
 <dce3cbe4-ee06-ec13-d307-5230e98df7c8@gmail.com>
Message-ID: <MWHPR05MB35822175B1FF606B449ECDD2F98E0@MWHPR05MB3582.namprd05.prod.outlook.com>

For what it's worth this also introduced

    > df = data.frame(v = package_version("1.2"))
    > rbind(df, df)$v
     [[1]]
     [1] 1 2

     [[2]]
     [1] 1 2

instead of

    > rbind(df, df)$v
    [1] '1.2' '1.2'

which shows up in Travis builds of Bioconductor packages

  https://stat.ethz.ch/pipermail/bioc-devel/2019-January/014506.html

and elsewhere

Martin Morgan

?On 1/3/19, 7:05 PM, "R-devel on behalf of Duncan Murdoch" <r-devel-bounces at r-project.org on behalf of murdoch.duncan at gmail.com> wrote:

    On 03/01/2019 3:37 p.m., Duncan Murdoch wrote:
    > I see this too; by bisection, it seems to have first appeared in r72943.
    
    Sorry, that was a typo.  I meant r75943.
    
    Duncan Murdoch
    
    > 
    > Duncan Murdoch
    > 
    > On 03/01/2019 2:18 p.m., I?aki Ucar wrote:
    >> Hi,
    >>
    >> I found the following issue in r-devel (2019-01-02 r75945):
    >>
    >> `foo<-` <- function(x, value) {
    >>     bar(x) <- value * x
    >>     x
    >> }
    >>
    >> `bar<-` <- function(x, value) {
    >>     stopifnot(all(value / x == 1))
    >>     x + value
    >> }
    >>
    >> `foo<-` <- compiler::cmpfun(`foo<-`)
    >> `bar<-` <- compiler::cmpfun(`bar<-`)
    >>
    >> x <- c(2, 2)
    >> foo(x) <- 1
    >> x # should be c(4, 4)
    >> #> [1] 3 3
    >>
    >> If the functions are not compiled or the stopifnot call is removed,
    >> the snippet works correctly. So it seems that something is messing
    >> around with the references to "value" when the call to stopifnot gets
    >> compiled, and the wrong "value" is modified. Note also that if "x <-
    >> 2", then the result is correct, 4.
    >>
    >> Regards,
    >>
    >
    
    ______________________________________________
    R-devel at r-project.org mailing list
    https://stat.ethz.ch/mailman/listinfo/r-devel
    


[Rd] Compiler + stopifnot bug
Martin Morgan