Hi all, I have a problem with a package that imports two other packages which both export a method for the `[` primitive function.
I set up a reproducible example here: https://github.com/kforner/namespaceImportFrom_problem.git Basically, the testPrimitiveImport package imports testPrimitiveExport1 and testPrimitiveExport2, which both export a S4 class and a `[` method for the class. Then: R CMD INSTALL -l lib testPrimitiveExport1 R CMD INSTALL -l lib testPrimitiveExport2 The command: R CMD INSTALL -l lib testPrimitiveImport gives me: Error in namespaceImportFrom(self, asNamespace(ns)) : trying to get slot "package" from an object of a basic class ("function") with no slots I get the same message if I check the package (with R CMD check), or even if I try to load it using devtools::load_all() I tried to investigate the problem, and I found that the error arises in the base::namespaceImportFrom() function, and more precisely in this block: for (n in impnames) if (exists(n, envir = impenv, inherits = FALSE)) { if (.isMethodsDispatchOn() && methods:::isGeneric(n, ns)) { genNs <- get(n, envir = ns)@package Here n is '[', and the get(n, envir = ns) expression returns .Primitive("["), which is a function and has no @package slot. This will only occur if exists(n, envir = impenv, inherits = FALSE) returns TRUE, i.e. if the '[' symbol is already in the imports env of the package. In my case, the first call to namespaceImportFrom() is for the first import of testPrimitiveExport1, which runs fine and populate the imports env with '['. But for the second call, exists(n, envir = impenv, inherits = FALSE) will be TRUE, so that the offending line will be called. I do not know if the problem is on my side, e.g. from a misconfiguration of the NAMESPACE file, or if it is a bug and in which case what should be done. Any feedback appreciated. Karl Forner [[alternative HTML version deleted]] ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel