Bug 15179 - Expressions with %any% operators do not deparse correctly.
Summary: Expressions with %any% operators do not deparse correctly.
Alias: None
Product: R
Classification: Unclassified
Component: Language (show other bugs)
Version: R 2.15.2
Hardware: All All
: P5 minor
Assignee: R-core
Depends on:
Reported: 2013-01-20 09:05 UTC by Peter Meilstrup
Modified: 2013-01-20 15:38 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Peter Meilstrup 2013-01-20 09:05:11 UTC
Expressions constructed using multiple %any% operators do not deparse with parentheses to preserve the order of operations. 

 x <- 2
 y <- pi
 z <- exp(1)
 `%^%` <- `^`

 expr <- quote( `%^%`(x, `%^%`(y,z)))
 print(expr) # should have parentheses
 eval(parse(text=deparse(expr))) #should be the same

interestingly deparsing appears to be correct if the functions are `%*%` or `%/%`, but not for other functions.
Comment 1 Duncan Murdoch 2013-01-20 14:02:23 UTC
Confirmed.  I'll fix it.  The reason %*% and %/% are handled properly is because they are built in operators.  The deparse code handles them separately from user-defined operators.  I'll fix the deparsing to be consistent.
Comment 2 Duncan Murdoch 2013-01-20 15:38:06 UTC
Fixed in R-devel and R-patched