[Rd] Strange parse behavior

From: Thomas Friedrichsmeier <thomas.friedrichsmeier_at_ruhr-uni-bochum.de>
Date: Thu 27 Apr 2006 - 19:06:18 GMT


Hi,

I discovered the following strange behavior in parse () on syntactically incorrect statements. This is on R 2.3.0 (linux). It may or may not have been present earlier than 2.3.0, but I only discovered it recently. I can see no mention of it in the NEWS file from trunk.

Consider these statements (the output I get is shown commented below each statement):

bad.syntax <- ")\nprint (\"hello\")\nprint (\"world\")"

try (parse (text=bad.syntax, n=-1)) # OK
# Error in parse(file, n, text, prompt) : syntax error in ")"
try (parse (text=bad.syntax, n=1)) # OK
# Error in parse(file, n, text, prompt) : syntax error in ")"
try (parse (text=bad.syntax, n=2)) # No error!
# NULL

try (parse (text=bad.syntax, n=3)) # No error!
# NULL

try (parse (text=bad.syntax, n=4)) # Misleading message
# Error in parse(file, n, text, prompt) : syntax error in:
# "print ("hello")
# print ("world")"

Probably there are not too many use cases of parse (n=x) with x not either -1 or 1, so it should not be a grave problem, but it just doesn't look right.

Regards
Thomas



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri Apr 28 05:07:01 2006

This archive was generated by hypermail 2.1.8 : Thu 27 Apr 2006 - 20:17:52 GMT