Skip to content

Commit

Permalink
swap try() and suppressWarnings()
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Jun 14, 2024
1 parent 4addef3 commit 6188a1d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion R/string.R
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ split_source = function(x, merge_comments = FALSE, line_number = FALSE) {
#' xfun::valid_syntax('1+')
#' xfun::valid_syntax(c('if(T){1+1}', 'else {2+2}'), silent = FALSE)
valid_syntax = function(code, silent = TRUE) {
!inherits(try(suppressWarnings(parse_only(code)), silent = silent), 'try-error')
!inherits(suppressWarnings(try(parse_only(code)), silent = silent), 'try-error')
}

#' Bump version numbers
Expand Down

0 comments on commit 6188a1d

Please sign in to comment.