Skip to content
This repository was archived by the owner on Oct 2, 2021. It is now read-only.

Commit 5bf20ab

Browse files
Do not replace <- with = if within a function call since it has other meaning.
1 parent 463100f commit 5bf20ab

File tree

6 files changed

+302
-260
lines changed

6 files changed

+302
-260
lines changed

R/rules-replacement.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ force_assignment_op <- function(pd) {
77

88
force_assignment_eq <- function(pd) {
99
to_replace <- pd$token == "LEFT_ASSIGN" & pd$text == "<-"
10-
pd$token[to_replace] <- "EQ_ASSIGN"
11-
pd$text[to_replace] <- "="
10+
if (any(to_replace) && next_terminal(pd)$token == "'('") {
11+
pd$token[to_replace] <- "EQ_ASSIGN"
12+
pd$text[to_replace] <- "="
13+
}
1214
pd
1315
}
1416

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
c(a <- 3)
2+
(a = b)
3+
((a = 3))

tests/testthat/mlr-style/eq-sub-replacement-in_tree

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
c(a <- 3)
2+
(a = b)
3+
((a = 3))

0 commit comments

Comments
 (0)