[Rd] warnings handled oddly in functions with browser calls (PR#13967)

richcalaway at revolution-computing.com richcalaway at revolution-computing.com
Wed Sep 23 20:45:15 CEST 2009


Full_Name: Rich Calaway
Version: 2.9.2
OS: Windows Vista
Submission from: (NULL) (65.47.30.18)


Consider the following function:

myfun <- function(){
	print(log(-1))
	browser()
	print("Good-bye!")
}

In the default case, with options(warn=0), if I call this function and type
nothing but standard browser commands (c, n, where, Q) at the browser prompt,
the warning produced by log(-1) is shown at the completion of the function, as
expected:

> myfun()
[1] NaN
Called from: myfun()
Browse[1]> c
[1] "Good-bye!"
Warning message:
In log(-1) : NaNs produced


However, if I type any other sort of R expression at the browser prompt, the
warning is issued immediately after that expression's output:

> myfun()
[1] NaN
Called from: myfun()
Browse[1]> print("hello")
[1] "hello"
Warning message:
In log(-1) : NaNs produced
Browse[1]> c
[1] "Good-bye!"

The warnings should be stored until myfun() returns.

This bug has been present at least since 2.7.2, and persists in the current
R-devel build.

Here's the sessionInfo():

> sessionInfo()
R version 2.10.0 Under development (unstable) (2009-09-21 r49780) 
i386-pc-mingw32 

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base



More information about the R-devel mailing list