[Rd] Strange parse behavior (PR#8815)
murdoch at stats.uwo.ca
murdoch at stats.uwo.ca
Thu Apr 27 21:42:37 CEST 2006
On 4/27/2006 3:06 PM, Thomas Friedrichsmeier wrote:
> 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.
I see the same results as you, in versions back to 1.9.1. I agree that
it looks like a bug, but not a new one. I've sent this reply to the
bugs list so it gets recorded. I won't have time to look into it soon.
Duncan Murdoch
More information about the R-devel
mailing list