[Rd] Bug in parseNamespaceFile or switch( , ... ) ?
Duncan Murdoch
murdoch.duncan at gmail.com
Sun Nov 28 23:54:02 CET 2010
On 27/11/2010 7:09 PM, Duncan Murdoch wrote:
> On 27/11/2010 6:50 PM, Duncan Murdoch wrote:
>> On 27/11/2010 5:58 PM, Charles C. Berry wrote:
>>>
>>> parseNamespaceFile() doesn't seem to detect misspelled directives. Looking
>>> at its code I see
>>>
>>> switch(as.character(e[[1L]]),
>>>
>>> <lots of args omitted here>,
>>>
>>> stop(gettextf("unknown namespace directive: %s",
>>> deparse(e)), call. = FALSE, domain = NA))
>>>
>>> but this doesn't seem to function as I expect, viz. to stop with an error
>>> if I type a wrong directive.
>>
>> You're right, there was a typo in parseNamespaceFile. (The typo was in
>> this line:
>>
>> "=", "<-" = {
>>
>> This should have been
>>
>> "=" =, "<-" = {
>>
>> Without the extra = sign, the "=" was taken as the default value of the
>> switch, and the stop() was never reached.
>>
>> Conceivably switch() should complain if it is called with more than one
>> default.
>
> I suspect when I fix this it's going to flush out some typos in packages
> on CRAN...
The first fix (to parseNamespaceFile) seems to have caught around 54
CRAN packages and 13 Bioconductor ones. Hopefully fixing these typos
will make the NAMESPACE function more as it was intended.
Fewer packages have been caught so far by the switch() change, but that
one requires the switch() to actually be executed, so more will show up
as the packages are used if their tests don't cover all of their code.
Thanks to Brian Ripley for running the tests. I'll email the
maintainers to let them know what's going on.
Duncan Murdoch
More information about the R-devel
mailing list