[Rd] bug: deparse sometimes omits parentheses for unary operators
Radford Neal
radford at cs.toronto.edu
Sat Jul 8 22:03:20 CEST 2017
> From: "Binder, Martin" <Ma.Binder at campus.lmu.de>
> To: r-devel at r-project.org
> Subject: [Rd] bug: deparse sometimes omits parentheses for unary
> operators
>
> Example (bad):
> > (expr = substitute(-a * 10, list(a = quote(if (TRUE) 1 else 0))))
> -if (TRUE) 1 else 0 * 10
>
> The parentheses around the "if"-construct are missing. The expected
> output (the true representation of the expression) is, in fact:
>
> -(if (TRUE) 1 else 0) * 10
It would also be OK for the result to be
(-if (TRUE) 1 else 0) * 10
It's possible that producing this form is more natural for the deparser.
There are a number of other bugs in the deparser, many of which I
fixed in the pqR deparser when doing a major rewrite, though I missed
the one you report above. You can see them at
http://www.pqr-project.org/NEWS.txt
Look for BUG FIXES under VERSION RELEASED 2015-09-14. Some are fixed
in R-3.4.0, but most remain.
Radford Neal
More information about the R-devel
mailing list