Created attachment 1648 [details]
long vector assignment followed by a print
The attached long (~32Kb) single-line file, consisting of a single vector assignment followed by a print, should print "ok" via Rscript. "Rscript test.R" exits before the print.
The error occurs based on input length not content. Adding a single character to the variable name or to a number causes correct execution, as does splitting the statements to two lines.
The problem appears limited to the console input. 'script("test.R")' executes correctly.
The problem occurs with R 3.1.1 on OS X, R 2.15.0 on OS X, and R 2.15.1 on Linux.
Hmm, the parse help page contains
...... The line-length limit is 4095 bytes when reading from the console
(which may impose a lower limit: see ‘An Introduction to R’).
and you say "The problem appears limited to the console input"
so there would not be a bug at all.
On the other hand, "Rscript test.R' is not about console input.
I've also tried R CMD BATCH test.R as an alternative, and that also
gives a problem. It produces a test.Rout; but the print("ok") part is not
NB: The line line length of the example file (test.R) is very close to
2^15 = 32768
I'd poked around with a debugger and saw the parse occurring with function R_ReplConsole in the call stack (R 2.15.1 on Linux using argument -f test.R), so I must be using console in an internal sense. :)
The parse appears to be using a 4096-length buffer, running out of space, adding one more buffer, then starting the parse over until the buffer chain is long enough. Not particularly efficient but should eventually work for arbitrarily long input. That said, shortening the vector assignment by 4096 characters avoids the bug. Lengthening the print statement also avoids the bug. The problem appears dependent on (1) the character length of the vector assignment and (2) the presence of the second expression.