Skip to content

Commit 27ea9ca

Browse files
committed
Update get_source_expressions to work with the fixed R parser in 3.6
1 parent 2e75e7f commit 27ea9ca

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: lintr
22
Title: A 'Linter' for R Code
3-
Version: 1.0.2
3+
Version: 1.0.3
44
Authors@R: person("Jim", "Hester", email = "james.f.hester@gmail.com", role = c("aut", "cre"))
55
URL: https://github.com/jimhester/lintr
66
BugReports: https://github.com/jimhester/lintr/issues

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# lintr 1.0.3 #
2+
* Fix tests to work with changes in the parser in R 3.6
3+
14
# lintr 1.0.2 #
25
* Fix tests to work with upcoming testthat release.
36

R/get_source_expressions.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ fix_eq_assign <- function(pc) {
214214
}
215215

216216
eq_assign_locs <- which(pc$token == "EQ_ASSIGN")
217-
if (length(eq_assign_locs) == 0L) {
217+
if (length(eq_assign_locs) == 0L || "equal_assign" %in% pc$token) {
218218
return(pc)
219219
}
220220

@@ -267,7 +267,7 @@ fix_eq_assign <- function(pc) {
267267

268268
parent[i] <- pc[eq_assign_locs[true_locs[i]], "parent"]
269269

270-
token[i] <- "expr"
270+
token[i] <- "expr" # R now uses "equal_assign"
271271

272272
terminal[i] <- FALSE
273273

@@ -315,5 +315,5 @@ top_level_expressions <- function(pc) {
315315
if (is.null(pc)) {
316316
return(NULL)
317317
}
318-
which(pc$parent == 0L & pc$token == "expr")
318+
which(pc$parent == 0L & pc$token %in% c("expr","equal_assign"))
319319
}

0 commit comments

Comments
 (0)