[R] Problem with reference Class that may be a bug in R

Jakub T. Jankiewicz jcub|c @end|ng |rom onet@p|
Fri Jul 23 19:21:03 CEST 2021


Hi,

I wanted to report a bug in R but was told without investigating that it's
probably my code have a bug. Note that references classes are not used
extensively (they were replaced by R6 in shiny because they are pain in the
neck).

The problem I've found looks like this:

I have two packages PackageA and PackageB in PackageA method of refClass I
have a call a function and I extend that method in PackageB and call super.
The problem is that R doesn't see the function in PackageA.

Code:

#' @export Foo
#' @exportClass Foo
Foo <- setRefClass(
  Class = "Foo",
  methods = list(
    foo = function(x) {
      message(paste(x, "[1]"))
    },
    bar = function(x) {
      lorem(x)
    }
  )
)



#' @export Bar
#' @exportClass Bar
Bar <- setRefClass(
  Class = "Bar",
  contains = "Foo",
  methods = list(
    foo = function(x) {
      callSuper(x)
      ipsum(x)
    },
    bar = function(x) {
      callSuper(x)
      ipsum(x)
    }
  )
)


In packageB R see functions ipsum local to the package but in it doesn't see
the function lorem in packageB when called from different package.

This is way to simple code to have bug in it.

You can see the code on this repo: https://github.com/jcubic/refClass with
explanation of the problem. This have nothing to do with importing since I
only need to import a class not a function that can be hidden. And there are
no problems in reference base class from packageA because I have:

Depends: packageA

in DESCRIPTION.

I have someone can check this, and confirm that this is a bug, but basically
when I've send this to request permission to add a bug to ask for help first,
even that I have experienced R developers in my Team that confirmed that this
is a bug in reference classes.

Best
Jakub

--
Jakub T. Jankiewicz, Web Developer
https://jcubic.pl/me



More information about the R-help mailing list