Re: [Rd] Bug in parseNamespaceFile or switch( , ... ) ?

From: Duncan Murdoch <>
Date: Sun, 28 Nov 2010 17:54:02 -0500

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 mailing list Received on Sun 28 Nov 2010 - 22:56:51 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 29 Nov 2010 - 04:40:27 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive