[Rd] R package builder silently continues after unclosed brace

Andy Manka @ndy@m@nk@ @end|ng |rom gm@||@com
Fri Jan 24 19:43:17 CET 2020

If you start a function in one file but don't close it, the package
will still build if you manage to close it in a later file. Like so:


function_a <- function(){
  print("this is function_a")

function_b <- function(){
  print("unclosed function_b")
# no closing }

function_c <- function(){
  print("function_c will be part of function_b")
#extra closing } to close function_b


The package builder will import `a.R` and `b.R`. And because
function_b was never closed, `c.R` gets subsumed into function_b. It's
pretty hard to debug, and it means that a production implementation
depends on the file structure never changing. (If you define a
function across `b.R` and `d.R`, you can never add an R script that
starts with `c`.)

What's the benefit of letting functions be defined across files in the
package builder? Or is it an unintended side effect?

I suspect the code for all this is in:

but it's beyond me.

The command I ran is:
"C:\Program Files\R\R-3.6.2\bin\x64\Rcmd.exe" build "c:\path\to\package"

More information about the R-devel mailing list