@@ -175,23 +175,19 @@ extract_glued_symbols <- function(expr) {
175175 if (length(glue_calls ) == 0L ) {
176176 return (character ())
177177 }
178- glued_symbols <- new.env(parent = emptyenv())
179178
180179 unexpected_error <- function (cond ) {
181180 stop(" Unexpected failure to parse glue call, please report: " , conditionMessage(cond )) # nocov
182181 }
183- for (cl in glue_calls ) {
182+ glued_symbols <- new.env(parent = emptyenv())
183+ for (call_text in xml2 :: xml_text(glue_calls )) {
184184 # TODO(michaelchirico): consider dropping tryCatch() here if we're more confident in our logic
185- parsed_cl <- tryCatch(
186- parse(text = xml2 :: xml_text(cl )),
187- error = unexpected_error ,
188- warning = unexpected_error
189- )[[1L ]]
190- parsed_cl [[" .envir" ]] <- glued_symbols
191- parsed_cl [[" .transformer" ]] <- symbol_extractor
185+ parsed_call <- tryCatch(str2lang(call_text ), error = unexpected_error , warning = unexpected_error )
186+ parsed_call [[" .envir" ]] <- glued_symbols
187+ parsed_call [[" .transformer" ]] <- symbol_extractor
192188 # #1459: syntax errors in glue'd code are ignored with warning, rather than crashing lint
193189 tryCatch(
194- eval(parsed_cl ),
190+ eval(parsed_call ),
195191 error = function (cond ) {
196192 warning(
197193 " Evaluating glue expression while testing for local variable usage failed: " ,
@@ -215,7 +211,9 @@ symbol_extractor <- function(text, envir, data) {
215211 return (" " )
216212 }
217213 parse_data <- utils :: getParseData(parsed_text )
218- symbols <- parse_data $ text [parse_data $ token == " SYMBOL" ]
214+
215+ # strip backticked symbols; `x` is the same as x.
216+ symbols <- gsub(" ^`(.*)`$" , " \\ 1" , parse_data $ text [parse_data $ token == " SYMBOL" ])
219217 for (sym in symbols ) {
220218 assign(sym , NULL , envir = envir )
221219 }
0 commit comments