[Rd] codetools: Suggestion to detect potentially unassigned variables

From: Henrik Bengtsson <hb_at_stat.berkeley.edu>
Date: Tue, 01 Jun 2010 20:41:38 +0200

This is just a note/wishlist/for the record:


foo1 <- function() {

foo2 <- function() {
  for (i in c()) res <- 1;

foo3 <- function() {
  while (FALSE) res <- 1;

foo4 <- function() {
  if (FALSE) res <- 1;

we get:

> foo1()

Error in foo1() : object 'res' not found
> foo2()

Error in foo2() : object 'res' not found
> foo3()

Error in foo3() : object 'res' not found
> foo4()

Error in foo4() : object 'res' not found

Running R CMD check on R v2.11.1pat we get:

An improvement would be to also report that:

foo2: variable 'res' may not be assigned
foo3: variable 'res' may not be assigned
foo4: variable 'res' may not be assigned


R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 01 Jun 2010 - 18:44:14 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 Wed 02 Jun 2010 - 08:40:56 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive