[Rd] Bug report for sealClass() in Core-maintained package "methods"
@gower @ending from bu@edu
Fri Oct 26 16:28:23 CEST 2018
I was just reminded from a comment in some code that I had submitted this bug report last year, but it does not appear to have been addressed in R 3.5.0.
Can this please be fixed, or is there a specific reason that it cannot be addressed?
From: Gower, Adam
Sent: Monday, June 19, 2017 11:56 AM
To: 'r-devel using r-project.org'
Subject: Bug report for sealClass() in Core-maintained package "methods"
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.
> setClass("foo", slots=c(name="character", age="integer"))
Error in list2env(list(<environment>), NULL, <environment>) :
names(x) must be a character vector of the same length as x
> sealClass("foo", where=.GlobalEnv)
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)[]
Thanks very much,
agower using bu.edu<mailto:agower using bu.edu>
[[alternative HTML version deleted]]
More information about the R-devel