Bug report for sealClass() in Core-maintained package "methods"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Bug report for sealClass() in Core-maintained package "methods"

Gower, Adam
Hello,

I have found that I cannot use sealClass() without specifying the 'where' argument.
I have found this issue in R 3.2.3 and R 3.4.0.
For example:
> setClass("foo", slots=c(name="character", age="integer"))
> isSealedClass("foo")
[1] FALSE
> sealClass("foo")
Error in list2env(list(<environment>), NULL, <environment>) :
  names(x) must be a character vector of the same length as x
> isSealedClass("foo")
[1] FALSE
> sealClass("foo", where=.GlobalEnv)
> isSealedClass("foo")
[1] TRUE

I found that this is because sealClass() includes the following line:
if (missing(where)) where <- findClass(Class, unique = "sealing the class", where = where)

Because findClass() always returns a list (even if argument 'unique' contains a character string), this assigns a list of length 1 to variable 'where'.
This then throws an error in the subsequent line
assignClassDef(Class, classDef, where)

For this reason, the abovementioned line should instead read:
if (missing(where)) where <- findClass(Class, unique = "sealing the class", where = where)[[1]]

Thanks very much,
Adam Gower
[hidden email]<mailto:[hidden email]>


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Loading...