← all packages

withr

no native code · R: 142 definitions, 24 typed strict, 101 gradual, prelude debt 47 · fuzzing: 21 definitions, 1 unsound, 8 accept calls outside their domain · tyr dc7f1a7 · Rsem 7bcb45f · NativeSem 770a1eb · rstt 2b2696f unpinned

R definitions

named top-level definitions
142 / 142 (100.0%)
not blocked by an unbound native symbol
142 / 142 (100.0%)
typed, gradual
101 / 142 (71.1%)
typed, strict
24 / 142 (16.9%)
47 of the strict failures are a name missing from the prelude.
mode
155 / 155

R definitions 155

R/aaa.R

the typed

env
timing: 0.004 s
source
the <- new.env()
R/aaa.R:1

on_package_load untypeabletyped

unbound variable (line 7)
unbound: substitute — a name the prelude does not declare
error detail
name: substitute
gradual mode: typed
((pkg: env | vec1, expr: any, env: any?) -> null)<>
timing: 0.041 s
source
on_package_load <- function(pkg, expr, env = parent.frame()) {
  expr <- substitute(expr)
  force(env)

  run <- function(...) {
    # Evaluate with promise semantics rather than `base::eval()`
    do <- NULL
    do.call(delayedAssign, list("do", expr, env))
    do
  }

  # Always register hook in case package is later unloaded & reloaded
  setHook(packageEvent(pkg, "onLoad"), run)

  # For compatibility with R < 4.0 where base isn't locked
  is_sealed <- function(pkg) {
    identical(pkg, "base") || environmentIsLocked(asNamespace(pkg))
  }

  # Run right away if package is already loaded but only if its
  # namespace is locked. The registering package might be a dependency
  # of `package`. In that case, `package` might not be fully populated
  # yet (#1225).
  if (isNamespaceLoaded(pkg) && is_sealed(pkg)) {
    run()
  }
}
R/aaa.R:6
R/standalone-defer.R

defer untypeabletyped

unbound variable (line 22)
unbound: as.call — a name the prelude does not declare
error detail
name: as.call
gradual mode: typed
((expr: any, envir: any?, after: any?) -> any)<>
timing: 0.037 s
source
defer <- function(expr, envir = parent.frame(), after = FALSE) {
  thunk <- as.call(list(function() expr))
  do.call(
    on.exit,
    list(thunk, add = TRUE, after = after),
    envir = envir
  )
}
R/standalone-defer.R:21
R/defer-exit.R

frame_loc typed any: envir no call in domain

((envir: any, frames: <@"[[", ...>) -> (DBL | INT)<difftime> | DBL1<~@"+", ...> | LGL<> | dbl<Date, ...> | <POSIXt, ...>)<>
timing: 0.579 s
fuzzing: 0 inside (none) · 0 outside (none)
source
frame_loc <- function(envir, frames) {
  n <- length(frames)
  if (!n) {
    return(0)
  }

  for (i in seq_along(frames)) {
    if (identical(frames[[n - i + 1]], envir)) {
      return(n - i + 1)
    }
  }

  0
}
R/defer-exit.R:63

knitr_exit_frame untypeable

untypeable application (line 5)
error detail
function: (envir: any, frames: <@"[[", ...>) --> (DBL | INT)<difftime> | DBL1<~@"+", ...> | LGL<> | dbl<Date, ...> | <POSIXt, ...>
argument: @('envir, list<>)
argument (not in the domain) may be: (new.env(), list())
timing: 0.063 s
source
knitr_exit_frame <- function(envir) {
  frames <- as.list(sys.frames())

  frame_loc <- frame_loc(envir, frames)
  if (!frame_loc) {
    return(envir)
  }

  knitr_ns <- asNamespace("knitr")

  # This doesn't handle correctly the recursive case (knitr called
  # within a chunk). Handling this would be a little fiddly for an
  # uncommon edge case.
  for (i in seq(1, frame_loc)) {
    if (identical(topenv(frames[[i]]), knitr_ns)) {
      return(frames[[i]])
    }
  }

  NULL
}
R/defer-exit.R:2

source_exit_frame_option untypeable

unbound variable (line 31)
unbound: sys.calls — a name the prelude does not declare
error detail
name: sys.calls
timing: 0.163 s
source
source_exit_frame_option <- function(envir, frames = as.list(sys.frames())) {
  calls <- as.list(sys.calls())

  i <- frame_loc(envir, frames)
  if (!i) {
    return(NULL)
  }

  if (i < 4) {
    return(NULL)
  }

  is_call <- function(x, fn) {
    is.call(x) && identical(x[[1]], fn)
  }
  calls <- as.list(calls)

  if (!is_call(calls[[i - 3]], quote(source))) {
    return(NULL)
  }
  if (!is_call(calls[[i - 2]], quote(withVisible))) {
    return(NULL)
  }
  if (!is_call(calls[[i - 1]], quote(eval))) {
    return(NULL)
  }
  if (!is_call(calls[[i - 0]], quote(eval))) {
    return(NULL)
  }

  frames[[i - 3]]
}
R/defer-exit.R:30

source_exit_frame untypeabletyped

unbound variable (line 25)
unbound: source_exit_frame_option — one of the package’s own names, itself untyped
error detail
name: source_exit_frame_option
gradual mode: typed
((envir: any) -> any)<>
timing: 0.003 s
source
source_exit_frame <- function(envir) {
  source_exit_frame_option(envir) %||% envir
}
R/defer-exit.R:24

knitr_in_progress typed fuzz ok

(() -> ff<>)<>
timing: 0.013 s
fuzzing: 1 inside (1 ok) · 1 outside (1 rejected)
source
knitr_in_progress <- function() {
  isTRUE(getOption("knitr.in.progress"))
}
R/defer-exit.R:81

in_knitr typed any: envir accepts outside

((envir: any) -> ff<>)<>
timing: 0.016 s
fuzzing: 7 inside (7 ok) · 8 outside (7 rejected, 1 accepted)

Accepted outside the domain envir: 1

parameterchangecallreturned
envirdropin_knitr()ff<> with { }
source
in_knitr <- function(envir) {
  knitr_in_progress() && identical(knitr::knit_global(), envir)
}
R/defer-exit.R:78
R/utils.R

make_call untypeabletyped

unbound variable (line 2)
unbound: as.call — a name the prelude does not declare
error detail
name: as.call
gradual mode: typed
((...: any) -> any)<>
timing: 0.009 s
source
make_call <- function(...) {
  as.call(list(...))
}
R/utils.R:1

vlapply skipped

error detail
Failure("Unsupported argument after an ellipsis.")
timing: 0.000 s
source
vlapply <- function(X, FUN, ..., FUN.VALUE = logical(1)) {
  vapply(X, FUN, ..., FUN.VALUE = FUN.VALUE)
}
R/utils.R:5

names2 typed any: x fuzz ok

((x: any) -> CHR)<>
timing: 0.053 s
fuzzing: 8 inside (8 ok) · 2 outside (2 rejected)
source
names2 <- function(x) {
  nms <- names(x)
  if (is.null(nms)) {
    rep("", length(x))
  } else {
    nms[is.na(nms)] <- ""
    nms
  }
}
R/utils.R:9

makevars_user untypeabletyped

unbound variable (line 23)
unbound: getRversion — a name the prelude does not declare
error detail
name: getRversion
gradual mode: typed
(() -> any)<>
timing: 0.182 s
source
makevars_user <- function() {
  if (getRversion() >= "3.3") {
    return(tools::makevars_user())
  }
  # Below is tools::makevars_user() from R 3.6.2
  m <- character()
  if (.Platform$OS.type == "windows") {
    if (!is.na(f <- Sys.getenv("R_MAKEVARS_USER", NA_character_))) {
      if (file.exists(f)) {
        m <- f
      }
    } else if (
      (Sys.getenv("R_ARCH") == "/x64") &&
        file.exists(f <- path.expand("~/.R/Makevars.win64"))
    ) {
      m <- f
    } else if (file.exists(f <- path.expand("~/.R/Makevars.win"))) {
      m <- f
    } else if (file.exists(f <- path.expand("~/.R/Makevars"))) {
      m <- f
    }
  } else {
    if (!is.na(f <- Sys.getenv("R_MAKEVARS_USER", NA_character_))) {
      if (file.exists(f)) {
        m <- f
      }
    } else if (
      file.exists(
        f <- path.expand(paste0("~/.R/Makevars-", Sys.getenv("R_PLATFORM")))
      )
    ) {
      m <- f
    } else if (file.exists(f <- path.expand("~/.R/Makevars"))) {
      m <- f
    }
  }
  m
}
R/utils.R:22

as_character typed accepts outside

(((x: vec | null) -> CHR<>)&((x: vec1) -> CHR1<>))<>
timing: 0.054 s
fuzzing: 8 inside (8 ok) · 7 outside (3 rejected, 4 accepted)

Accepted outside the domain x: 4

parameterchangecallreturned
xkind:listas_character("x" = list())(CHR & ~vec1)<> with { }
xwrapas_character(list(NA_complex_))"NA"<> with { }
xwrapas_character(list(as.raw(c(255))))"as.raw(0xff)"<> with { }
xwrapas_character("x" = list(TRUE))"TRUE"<> with { }
source
as_character <- function(x) {
  nms <- names(x)
  res <- as.character(x)
  names(res) <- nms
  res
}
R/utils.R:61

list_combine untypeable

untypeable application (line 69)
error detail
function: (v('I916) --> v1('I916)) & ({ 'I917 } --> 'I917)
argument: CHR<> | null
argument (not in the domain) may be: NULL
timing: 0.028 s
source
list_combine <- function(rhs, lhs) {
  for (nme in names(lhs)) {
    rhs[nme] <- lhs[nme]
  }
  rhs
}
R/utils.R:68

auto_splice typed accepts outside

∀'a,'b,'c. (((x: 'a & <@"[[", ...>) -> any) & ((x: 'a & v('c)<~@"[[", ...>) -> v1('c)<> | v('c)<~@"[[", ...> & 'a) & ((x: 'a & { }<~@"[[", ...>) -> { }<~@"[[", ...> & 'a) & ((x: 'a & { 'b }<~@"[[", ...>) -> 'b | { 'b }<~@"[[", ...> & 'a) & ((x: 'a & { 'b & list }<~@"[[", ...>) -> 'b | { 'b & list }<~@"[[", ...> & 'a))<>
timing: 0.928 s
fuzzing: 16 inside (16 ok) · 8 outside (7 rejected, 1 accepted)
type drawn from: (((x: 'x & <@"[[", ...>) -> any) & ((x: 'x & v('I1034)<~@"[[", ...>) -> v1('I1034)<> | v('I1034)<~@"[[", ...> & 'x) & ((x: 'x & { }<~@"[[", ...>) -> { }<~@"[[", ...> & 'x) & ((x: 'x & { 'I997 }<~@"[[", ...>) -> 'I997 | { 'I997 }<~@"[[", ...> & 'x) & ((x: 'x & { 'I997 & list }<~@"[[", ...>) -> 'I997 | { 'I997 & list }<~@"[[", ...> & 'x))<>

Accepted outside the domain x: 1

parameterchangecallreturned
xkind:nullauto_splice(NULL)null
source
auto_splice <- function(x) {
  if (length(x) == 1 && is.null(names(x)) && is.list(x[[1]])) {
    x[[1]]
  } else {
    x
  }
}
R/utils.R:76

setNames typed unsound

∀'a. ((x: 'a?, nm: 'a & (vec | null)) -> 'a)<>
timing: 0.035 s
fuzzing: 20 inside (1 ok, 14 unsound, 5 error type) · 8 outside (6 rejected, 2 accepted)
type drawn from: ((x: 'nm?, nm: 'nm & (vec | null)) -> 'nm)<>

Counterexamples

callpredictedreturned
setNames(c(FALSE, FALSE), FALSE)LGL<> with { }(LGL & ~vec1)<> with { names: (CHR & ~vec1)<> with { } }
setNames(integer(0), integer(0))INT<> with { }(INT & ~vec1)<> with { names: (CHR & ~vec1)<> with { } }
setNames("x" = c(NA_real_, 1000000, Inf, 0, 0.5), "nm" = c(-2147483647, Inf, -2.5, NA_real_, 1))DBL<> with { }(DBL & ~vec1)<> with { names: (CHR & ~vec1)<> with { } }
setNames("x" = c("a", "x y", "é", NA_character_, ""), "nm" = "x y")CHR<> with { }(CHR & ~vec1)<> with { names: (CHR & ~vec1)<> with { } }
setNames(as.raw(c(255, 255)), "nm" = as.raw(c(255)))raw<> with { }(raw & ~vec1)<> with { names: (CHR & ~vec1)<> with { } }
setNames("x" = 2, "nm" = 1)^DBL1<> with { }2.<> with { names: "1"<> with { } }
and 8 more

Accepted outside the domain nm: 2

parameterchangecallreturned
nmwrapsetNames("x" = c(NA_real_, 1000000, Inf, 0, 0.5), "nm" = list(c(-2147483647, Inf, -2.5, NA_real_, 1)))(DBL & ~vec1)<> with { names: (CHR & ~vec1)<> with { } }
nmwrapsetNames("x" = 2, "nm" = list(1))2.<> with { names: "1"<> with { } }

Other calls inside the domain

callverdicterror
setNames(complex(0), "nm" = c(complex(real = 1, imaginary = -2), complex(real = 0, imaginary = 0), complex(real = 0, imaginary = 0), complex(real = 1, imaginary = -2), complex(real = 0, imaginary = 0)))error_typebase::<-: 'names' attribute [5] must be the same length as the vector [0]
setNames(logical(0), "nm" = c(NA, NA, NA, NA, TRUE))error_typebase::<-: 'names' attribute [5] must be the same length as the vector [0]
setNames(structure(-2147483647L, "levels" = c("a", "a"), class = "factor"), structure(c(0L, 42L, NA_integer_, 2147483647L, 2L), "levels" = "", class = "factor"))error_typebase::as.character.factor: malformed factor
setNames("x" = character(0), "nm" = c("é", ""))error_typebase::<-: 'names' attribute [2] must be the same length as the vector [0]
setNames(numeric(0), "nm" = 2)error_typebase::<-: 'names' attribute [1] must be the same length as the vector [0]
source
setNames <- function(x = nm, nm) {
  names(x) <- nm
  x
}
R/utils.R:84

is_interactive typed fuzz ok

(() -> LGL1<>)<>
timing: 0.054 s
fuzzing: 1 inside (1 ok) · 1 outside (1 rejected)
source
is_interactive <- function() {
  opt <- getOption("rlang_interactive")
  if (!is.null(opt)) {
    return(opt)
  }
  if (knitr_in_progress()) {
    return(FALSE)
  }
  if (identical(Sys.getenv("TESTTHAT"), "true")) {
    return(FALSE)
  }
  interactive()
}
R/utils.R:90

%||% typed accepts outside

∀'a,'b. (((x: 'b & null, y: 'a) -> 'a)&((x: 'b \ null, y: 'a) -> 'b \ null))<>
timing: 0.043 s
fuzzing: 20 inside (20 ok) · 8 outside (5 rejected, 3 accepted)
type drawn from: (((x: 'x & null, y: 'y) -> 'y) & ((x: 'x \ null, y: 'y) -> 'x \ null))<>

Accepted outside the domain x: 2, y: 1

parameterchangecallreturned
xdrop%||%(as.raw(c(0, 255, 255, 255, 255)))(raw & ~vec1)<> with { }
xdrop%||%(as.raw(c(0, 0, 0, 255, 0)))(raw & ~vec1)<> with { }
ydrop%||%(NA_integer_)(INT1 \ ^INT1)<> with { }
source
`%||%` <- function(x, y) {
  if (is.null(x)) y else x
}
R/utils.R:104
R/local_.R

<statement> typed

timing: 0.000 s
source
NULL
R/local_.R:2

local_ skipped

error detail
File "Rsem/lang/PAst.ml", line 143, characters 29-35: Assertion failed
timing: 0.000 s
source
local_ <- function(
  set,
  reset = set,
  get = NULL,
  ...,
  envir = parent.frame(),
  new = TRUE,
  dots = FALSE
) {
  if (!missing(...)) {
    stop("`...` must be empty.")
  }

  fmls <- formals(set)

  if (length(fmls) > 0L) {
    # Called pass all extra formals on
    called_fmls <- setNames(lapply(names(fmls), as.symbol), names(fmls))

    # Special case for dots. If `set()` and/or `get()` take dots, it
    # is assumed they implement `options()`-like semantic: a list
    # passed as first argument is automatically spliced in the dots.
    names(called_fmls)[names(called_fmls) == "..."] <- ""

    if (new) {
      if (dots) {
        called_fmls[[1]] <- as.symbol(".new")
        fun_args <- c(alist(.new = list(), ... = ), fmls[-1L])
      } else {
        called_fmls[[1]] <- as.symbol("new")
        fun_args <- c(alist(new = list()), fmls[-1L])
      }
    } else {
      fun_args <- fmls
    }
  } else {
    # no formals
    called_fmls <- NULL

    fun_args <- alist()
  }

  set_call <- as.call(c(substitute(set), called_fmls))
  reset <- if (missing(reset)) substitute(set) else substitute(reset)

  if (dots) {
    modify_call <- quote(.new <- list_combine(as.list(.new), list(...)))
  } else {
    modify_call <- NULL
  }

  if (is.null(get)) {
    fun <- eval(bquote(function(args) {
      .(modify_call)
      old <- .(set_call)
      withr::defer(.(reset)(old), envir = .local_envir)
      invisible(old)
    }))
  } else {
    get_call <- as.call(c(substitute(get), called_fmls))
    fun <- eval(bquote(function(args) {
      .(modify_call)
      old <- .(get_call)
      withr::defer(.(reset)(old), envir = .local_envir)
      .(set_call)
      invisible(old)
    }))
  }

  # substitute does not work on arguments, so we need to fix them manually
  formals(fun) <- c(fun_args, alist(.local_envir = parent.frame()))
  environment(fun) <- envir

  fun
}
R/local_.R:6
R/with_.R

<statement> typed

timing: 0.000 s
source
NULL
R/with_.R:2

with_ untypeable

untypeable application of base::missing (line 70)
error detail
argument: @(...: ('_ell, empty? | `_ell))
failing call: base::missing()
timing: 0.127 s
source
with_ <- function(
  set,
  reset = set,
  get = NULL,
  ...,
  envir = parent.frame(),
  new = TRUE
) {
  if (!missing(...)) {
    stop("`...` must be empty.")
  }

  fmls <- formals(set)

  if (length(fmls) > 0L) {
    # Called pass all extra formals on
    called_fmls <- setNames(lapply(names(fmls), as.symbol), names(fmls))

    # Special case for dots. If `set()` and/or `get()` take dots, it
    # is assumed they implement `options()`-like semantic: a list
    # passed as first argument is automatically spliced in the dots.
    names(called_fmls)[names(called_fmls) == "..."] <- ""

    if (new) {
      # rename first formal to new
      called_fmls[[1]] <- as.symbol("new")

      fun_args <- c(alist(new = , code = ), fmls[-1L])
    } else {
      fun_args <- c(alist(code = ), fmls)
    }
  } else {
    # no formals -- only have code
    called_fmls <- NULL

    fun_args <- alist(code = )
  }

  set_call <- as.call(c(substitute(set), called_fmls))
  reset <- if (missing(reset)) substitute(set) else substitute(reset)

  if (is.null(get)) {
    fun <- eval(bquote(function(args) {
      old <- .(set_call)
      on.exit(.(reset)(old))
      force(code)
    }))
  } else {
    get_call <- as.call(c(substitute(get), called_fmls))
    fun <- eval(bquote(function(args) {
      old <- .(get_call)
      on.exit(.(reset)(old))
      .(set_call)
      force(code)
    }))
  }

  # substitute does not work on arguments, so we need to fix them manually
  formals(fun) <- fun_args
  environment(fun) <- envir

  fun
}
R/with_.R:62

merge_new timeout

timing: 20.00 s
source
merge_new <- function(old, new, action, merge_fun = c) {
  action <- match.arg(action, c("replace", "prefix", "suffix"))

  if (action == "suffix") {
    new <- merge_fun(old, new)
  } else if (action == "prefix") {
    new <- merge_fun(new, old)
  }
  new
}
R/with_.R:126

is.named typed any: x fuzz ok

((x: any) -> ff<> | tt<>)<>
timing: 0.049 s
fuzzing: 7 inside (7 ok) · 8 outside (8 rejected)
source
is.named <- function(x) {
  !is.null(names(x)) && all(names(x) != "")
}
R/with_.R:137
R/env.R

as_envvars untypeabletyped

unbound variable (line 48)
unbound: vlapply — one of the package’s own names, itself untyped
error detail
name: vlapply
gradual mode: typed
((envs: any) -> any)<>
timing: 0.042 s
source
as_envvars <- function(envs) {
  if (length(envs) == 0) {
    return(envs)
  }

  stopifnot(is.named(envs))

  # if any envs are null make them NA instead
  envs[vlapply(envs, is.null)] <- NA

  # if there are duplicated entries keep only the last one
  envs <- envs[!duplicated(names(envs), fromLast = TRUE)]

  envs
}
R/env.R:40

get_envvar untypeable

unbound variable (line 4)
unbound: as_envvars — one of the package’s own names, itself untyped
error detail
name: as_envvars
timing: 0.008 s
source
get_envvar <- function(envs, action = "replace") {
  envs <- as_envvars(envs)
  Sys.getenv(names(envs), names = TRUE, unset = NA)
}
R/env.R:3

set_envvar skipped

error detail
File "Rsem/lang/PAst.ml", line 210, characters 14-20: Assertion failed
timing: 0.000 s
source
set_envvar <- function(envs, action = "replace") {
  envs <- as_envvars(envs)

  stopifnot(is.character(action), length(action) == 1)
  action <- match.arg(action, c("replace", "prefix", "suffix"))

  if (length(envs) == 0) {
    return()
  }

  old <- Sys.getenv(names(envs), names = TRUE, unset = NA)
  set <- !is.na(envs)

  both_set <- set & !is.na(old)
  if (any(both_set)) {
    if (action == "prefix") {
      envs[both_set] <- paste(envs[both_set], old[both_set])
    } else if (action == "suffix") {
      envs[both_set] <- paste(old[both_set], envs[both_set])
    }
  }

  if (any(set)) {
    do.call("Sys.setenv", as.list(envs[set]))
  }
  if (any(!set)) {
    Sys.unsetenv(names(envs)[!set])
  }

  invisible(old)
}
R/env.R:8

with_envvar untypeabletyped

unbound variable (line 77)
unbound: set_envvar — one of the package’s own names, itself untyped
error detail
name: set_envvar
gradual mode: typed
any
timing: 0.000 s
source
with_envvar <- with_(set_envvar, get = get_envvar)
R/env.R:77

local_envvar untypeabletyped

unbound variable (line 81)
unbound: set_envvar — one of the package’s own names, itself untyped
error detail
name: set_envvar
gradual mode: typed
any
timing: 0.000 s
source
local_envvar <- local_(set_envvar, get = get_envvar, dots = TRUE)
R/env.R:81
R/locale.R

as_locale_cats typed fuzz ok

(((cats: vec | null) -> CHR<>)&((cats: vec1) -> CHR1<>))<>
timing: 0.069 s
fuzzing: 7 inside (7 error pkg) · 8 outside (8 rejected)

Other calls inside the domain

callverdicterror
as_locale_cats(NULL)error_pkgwithr::as_locale_cats: is.named(cats) is not TRUE
as_locale_cats("cats" = as.raw(c(255)))error_pkgwithr::as_locale_cats: is.named(cats) is not TRUE
as_locale_cats("cats" = 1L)error_pkgwithr::as_locale_cats: is.named(cats) is not TRUE
as_locale_cats("cats" = complex(real = 0, imaginary = 0))error_pkgwithr::as_locale_cats: is.named(cats) is not TRUE
as_locale_cats("cats" = complex(real = 1, imaginary = -2))error_pkgwithr::as_locale_cats: is.named(cats) is not TRUE
as_locale_cats("cats" = c(42L, -1L))error_pkgwithr::as_locale_cats: is.named(cats) is not TRUE
and 1 more
source
as_locale_cats <- function(cats) {
  cats <- as_character(cats)
  stopifnot(is.named(cats))

  if ("LC_ALL" %in% names(cats)) {
    stop("Setting LC_ALL category not implemented.", call. = FALSE)
  }

  cats
}
R/locale.R:73

get_locale untypeable

untypeable application of base::vapply (line 69)
error detail
argument: @(CHR<> | null, (category: vec1?) -> CHR1<>, CHR1<>)
failing call: base::vapply(NA_character_, function(...) NULL, NA_character_)
timing: 0.146 s
source
get_locale <- function(cats) {
  vapply(names(cats), Sys.getlocale, character(1))
}
R/locale.R:69

set_locale untypeabletyped

unbound variable (line 67)
unbound: mapply — a name the prelude does not declare
error detail
name: mapply
gradual mode: typed
((cats: any) -> any)<>
timing: 0.015 s
source
set_locale <- function(cats) {
  mapply(Sys.setlocale, names(cats), cats)
}
R/locale.R:66

local_locale untypeable

unbound variable (line 46)
unbound: list_combine — one of the package’s own names, itself untyped
error detail
name: list_combine
timing: 0.065 s
source
local_locale <- function(.new = list(), ..., .local_envir = parent.frame()) {
  new <- list_combine(as.list(.new), list(...))
  cats <- as_locale_cats(new)

  # <https://github.com/r-lib/withr/issues/179>
  # R supports setting LC_COLLATE to C via envvar. When that is the
  # case, it takes precedence over the currently set locale. We need
  # to set both the envvar and the locale for collate to fully take
  # effect.
  if ("LC_COLLATE" %in% names(cats)) {
    collate <- cats["LC_COLLATE"]
    local_envvar(collate, .local_envir = .local_envir)
  }

  old <- get_locale(cats)
  defer(set_locale(old), envir = .local_envir)
  set_locale(cats)

  invisible(old)
}
R/locale.R:45

with_locale untypeabletyped

unbound variable (line 39)
unbound: local_locale — one of the package’s own names, itself untyped
error detail
name: local_locale
gradual mode: typed
∀'a. ((new: any, code: 'a) -> 'a)<>
timing: 0.003 s
source
with_locale <- function(new, code) {
  local_locale(new)
  code
}
R/locale.R:38
R/collate.R

with_collate untypeabletyped

unbound variable (line 24)
unbound: with_locale — one of the package’s own names, itself untyped
error detail
name: with_locale
gradual mode: typed
∀'a. ((new: list | null, code: 'a) | (new: vec | null, code: 'a) -> 'a)<>
timing: 0.043 s
source
with_collate <- function(new, code) {
  with_locale(c(LC_COLLATE = new), code)
}
R/collate.R:23

local_collate untypeabletyped

unbound variable (line 30)
unbound: local_locale — one of the package’s own names, itself untyped
error detail
name: local_locale
gradual mode: typed
((new: (list | null)?, .local_envir: any?) -> any)<>
timing: 0.035 s
source
local_collate <- function(new = list(), .local_envir = parent.frame()) {
  local_locale(c(LC_COLLATE = new), .local_envir = .local_envir)
}
R/collate.R:29
R/connection.R

with_connection untypeabletyped

unbound variable (line 25)
unbound: on.exit — a name the prelude does not declare
error detail
name: on.exit
gradual mode: typed
((con: { <connection, ...> }, code: any) -> any)<>
timing: 0.053 s
source
with_connection <- function(con, code) {
  stopifnot(all(is.named(con)))

  on.exit({
    for (connection in con) {
      close(connection)
    }
  })
  eval(substitute(code), envir = con, enclos = parent.frame())
}
R/connection.R:22

local_connection untypeabletyped

unbound variable (line 36)
unbound: defer — one of the package’s own names, itself untyped
error detail
name: defer
gradual mode: typed
∀'a. ((con: 'a & <connection, ...>, .local_envir: any?) -> <connection, ...> & 'a)<>
timing: 0.014 s
source
local_connection <- function(con, .local_envir = parent.frame()) {
  defer(close(con), envir = .local_envir)
  con
}
R/connection.R:35
R/db.R

with_db_connection untypeabletyped

unbound variable (line 30)
unbound: methods::is — a name the prelude does not declare
error detail
name: methods::is
gradual mode: typed
∀'a. ((con: list | vec, code: 'a) -> 'a)<>
timing: 0.020 s
source
with_db_connection <- function(con, code) {
  requireNamespace("DBI", quietly = TRUE)

  stopifnot(all(is.named(con)))
  stopifnot(all(vlapply(con, methods::is, "DBIConnection")))

  nme <- tempfile()
  (get("attach", baseenv()))(con, name = nme, warn.conflicts = FALSE)
  on.exit({
    for (connection in con) {
      DBI::dbDisconnect(connection)
    }
    detach(nme, character.only = TRUE)
  })
  force(code)
}
R/db.R:26

local_db_connection untypeabletyped

unbound variable (line 47)
unbound: methods::is — a name the prelude does not declare
error detail
name: methods::is
gradual mode: typed
∀'a. ((con: 'a, .local_envir: any?) -> 'a)<>
timing: 0.010 s
source
local_db_connection <- function(con, .local_envir = parent.frame()) {
  requireNamespace("DBI", quietly = TRUE)
  stopifnot(methods::is(con, "DBIConnection"))

  defer(DBI::dbDisconnect(con), envir = .local_envir)
  con
}
R/db.R:45
R/options.R

get_options typed any: new_options fuzz ok

((new_options: any) -> any)<>
timing: 0.020 s
fuzzing: 6 inside (6 ok) · 7 outside (7 rejected)
source
get_options <- function(new_options) {
  do.call(options, as.list(names(new_options)))
}
R/options.R:5

set_options typed any: new_options fuzz ok

((new_options: any) -> any)<>
timing: 0.045 s
fuzzing: 7 inside (4 ok, 1 error pkg, 2 error type) · 8 outside (8 rejected)

Other calls inside the domain

callverdicterror
set_options("new_options" = as.name("x"))error_pkgwithr::set_options: object 'x' not found
set_options(function(...) list(as.name("x")))error_typebase::function (...) .Internal(options(...)): argument is missing, with no default
set_options("new_options" = local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }))error_type::as.vector: cannot coerce type 'externalptr' to vector of type 'list'
source
set_options <- function(new_options) {
  do.call(options, as.list(new_options))
}
R/options.R:8

reset_options typed any: old_options fuzz ok

((old_options: any) -> list<>)<>
timing: 0.008 s
fuzzing: 6 inside (1 ok, 5 error type) · 7 outside (7 rejected)

Other calls inside the domain

callverdicterror
reset_options(function(...) as.name("x"))error_typebase::options: invalid argument
reset_options(function(...) NULL)error_typebase::options: invalid argument
reset_options(function(...) quote(f(x)))error_typebase::options: invalid argument
reset_options(new.env())error_typebase::options: invalid argument
reset_options("old_options" = as.name("x"))error_typebase::options: invalid argument
source
reset_options <- function(old_options) {
  options(old_options)
}
R/options.R:11

with_options untypeabletyped

unbound variable (line 52)
unbound: with_ — one of the package’s own names, itself untyped
error detail
name: with_
gradual mode: typed
any
timing: 0.002 s
source
with_options <- with_(
  set_options,
  reset_options
)
R/options.R:52

local_options untypeabletyped

unbound variable (line 59)
unbound: local_ — one of the package’s own names, itself untyped
error detail
name: local_
gradual mode: typed
any
timing: 0.001 s
source
local_options <- local_(
  set_options,
  reset_options,
  get = get_options,
  dots = TRUE
)
R/options.R:59
R/defer.R

<statement> typed

timing: 0.000 s
source
NULL
R/defer.R:3

knitr_handlers typed accepts outside

∀'a. (((envir: any with { withr_knitr_handlers: 'a \ null, any }) -> 'a \ null)&((envir: any with { withr_knitr_handlers: 'a, any }) -> { }<> | 'a \ null))<>
timing: 0.074 s
fuzzing: 20 inside (20 ok) · 8 outside (3 rejected, 5 accepted)
type drawn from: (((envir: any with { withr_knitr_handlers: 'I1422 \ null, any }) -> 'I1422 \ null) & ((envir: any with { withr_knitr_handlers: 'I1422, any }) -> { }<> | 'I1422 \ null))<>

Accepted outside the domain envir: 5

parameterchangecallreturned
envirattr:drop:withr_knitr_handlersknitr_handlers(quote(f(x))){ }<> with { }
envirkind:chrknitr_handlers("envir" = "fuzz"){ }<> with { }
envirkind:nullknitr_handlers(NULL){ }<> with { }
envirkind:symknitr_handlers("envir" = as.name("x")){ }<> with { }
envirwrapknitr_handlers("envir" = list(structure(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), "withr_knitr_handlers" = 2147483647))){ }<> with { }
source
knitr_handlers <- function(envir) {
  attr(envir, "withr_knitr_handlers") %||% list()
}
R/defer.R:272

defer_knitr_run skipped

error detail
Failure("Unsupported positional argument after a named one.")
timing: 0.000 s
source
defer_knitr_run <- function(
  envir,
  handlers = knitr_handlers(envir)
) {
  defer(envir = envir, {
    for (expr in handlers) {
      eval(expr, envir)
    }
  })
}
R/defer.R:277

defer_knitr untypeabletyped

unbound variable (line 252)
unbound: knitr_exit_frame — one of the package’s own names, itself untyped
error detail
name: knitr_exit_frame
gradual mode: typed
((expr: any, envir: any, priority: (vec | null)?) -> null)<>
timing: 0.110 s
source
defer_knitr <- function(expr, envir, priority = c("first", "last")) {
  priority <- match.arg(priority, choices = c("first", "last"))

  envir <- knitr_exit_frame(envir)
  handler <- as.call(list(function() expr))

  handlers <- knitr_handlers(envir)

  # Add `on.exit` hook if run for first time
  if (!length(handlers)) {
    defer_knitr_run(envir)
  }

  if (priority == "first") {
    handlers <- c(list(handler), handlers)
  } else {
    handlers <- c(handlers, list(handler))
  }
  attr(envir, "withr_knitr_handlers") <- handlers

  invisible(NULL)
}
R/defer.R:249

frame_clear_exits untypeabletyped

unbound variable (line 176)
unbound: on.exit — a name the prelude does not declare
error detail
name: on.exit
gradual mode: typed
((frame: any?) -> any)<>
timing: 0.003 s
source
frame_clear_exits <- function(frame = parent.frame()) {
  do.call(on.exit, list(), envir = frame)
}
R/defer.R:175

is_top_level_global_env untypeable

untypeable application of base::vapply (line 240)
error detail
argument: @({ env }<> | null | 'frames, (x: any, y: any, ...: any) -> LGL1<>, (LGL1 & ~^LGL1)<>, env)
failing call: base::vapply(list(), function(...) NULL, NA, new.env())
timing: 0.115 s
source
is_top_level_global_env <- function(envir, frames = sys.frames()) {
  if (!identical(envir, globalenv())) {
    return(FALSE)
  }

  # Check if another global environment is on the stack
  !any(vapply(frames, identical, NA, globalenv()))
}
R/defer.R:234

deferred_clear skipped

error detail
Invalid_argument("Cannot assign to an immutable variable.")
timing: 0.001 s
source
deferred_clear <- function(envir = parent.frame()) {
  if (is_top_level_global_env(envir)) {
    the$global_exits <- list()
  } else {
    frame_clear_exits(envir)
  }
  invisible()
}
R/defer.R:181

frame_exits untypeabletyped

unbound variable (line 161)
unbound: sys.on.exit — a name the prelude does not declare
error detail
name: sys.on.exit
gradual mode: typed
((frame: any?) -> any)<>
timing: 0.016 s
source
frame_exits <- function(frame = parent.frame()) {
  exits <- do.call(sys.on.exit, list(), envir = frame)

  # The exit expressions are stored in a single object that is
  # evaluated on exit. This can be NULL, an expression, or multiple
  # expressions wrapped in {. We convert this data structure to a list
  # of expressions.
  if (is.null(exits)) {
    list()
  } else if (identical(exits[[1]], quote(`{`))) {
    as.list(exits[-1])
  } else {
    list(exits)
  }
}
R/defer.R:160

deferred_run untypeable

unbound variable (line 134)
unbound: is_top_level_global_env — one of the package’s own names, itself untyped
error detail
name: is_top_level_global_env
timing: 0.056 s
source
deferred_run <- function(envir = parent.frame()) {
  if (knitr_in_progress() && identical(envir, knitr::knit_global())) {
    # The handlers are thunks so we don't need to clear them.
    # They will only be run once.
    frame <- knitr_exit_frame(envir)
    handlers <- knitr_handlers(frame)
  } else {
    if (is_top_level_global_env(envir)) {
      handlers <- the$global_exits
    } else {
      handlers <- frame_exits(envir)
    }
    deferred_clear(envir)
  }

  n <- length(handlers)
  i <- 0L

  if (!n) {
    message("No deferred expressions to run")
    return(invisible(NULL))
  }

  defer(message(
    sprintf("Ran %s/%s deferred expressions", i, n)
  ))

  for (expr in handlers) {
    eval(expr, envir)
    i <- i + 1L
  }
}
R/defer.R:127

global_defer skipped

error detail
Invalid_argument("Cannot assign to an immutable variable.")
timing: 0.017 s
source
global_defer <- function(expr, priority = c("first", "last")) {
  priority <- match.arg(priority, choices = c("first", "last"))

  env <- globalenv()
  handlers <- the$global_exits

  if (!length(handlers)) {
    # For session scopes we use reg.finalizer()
    if (is_interactive()) {
      message(
        sprintf("Setting global deferred event(s).\n"),
        "i These will be run:\n",
        "  * Automatically, when the R session ends.\n",
        "  * On demand, if you call `withr::deferred_run()`.\n",
        "i Use `withr::deferred_clear()` to clear them without executing."
      )
    }
    reg.finalizer(env, function(env) deferred_run(env), onexit = TRUE)
  }

  handler <- as.call(list(function() expr))

  if (priority == "first") {
    the$global_exits <- c(list(handler), handlers)
  } else {
    the$global_exits <- c(handlers, list(handler))
  }

  invisible(NULL)
}
R/defer.R:199

defer untypeable

unbound variable (line 77)
unbound: source_exit_frame_option — one of the package’s own names, itself untyped
error detail
name: source_exit_frame_option
timing: 0.216 s
source
defer <- function(expr, envir = parent.frame(), priority = c("first", "last")) {
  if (identical(envir, globalenv())) {
    source_frame <- source_exit_frame_option(envir)
    if (!is.null(source_frame)) {
      # Automatically enable `source()` special-casing for the global
      # environment. This is the default for `source()` and the normal
      # case when users run scripts. This also happens in R CMD check
      # when withr is used inside an example because an R example is
      # run inside `withAutoprint()` which uses `source()`.
      local_options(withr.hook_source = TRUE)
      # And fallthrough to the default `defer()` handling. Within
      # `source()` we don't require manual calling of
      # `deferred_run()`.
    } else if (is_top_level_global_env(envir)) {
      global_defer(expr, priority = priority)
      return(invisible(NULL))
    }
  }

  priority <- match.arg(priority, choices = c("first", "last"))

  if (knitr_in_progress() && identical(envir, knitr::knit_global())) {
    return(defer_knitr(expr, envir, priority = priority))
  }

  # Don't handle `source()` by default to avoid a performance hit
  if (!is.null(getOption("withr.hook_source"))) {
    envir <- source_exit_frame(envir)
  }

  thunk <- as.call(list(function() expr))
  after <- priority == "last"

  do.call(
    base::on.exit,
    list(thunk, TRUE, after),
    envir = envir
  )
}
R/defer.R:75

<statement> typed

timing: 0.003 s
source
formals(defer)[["priority"]] <- eval(formals(defer)[["priority"]])
R/defer.R:116

defer_parent untypeable

unbound variable (line 122)
unbound: defer — one of the package’s own names, itself untyped
error detail
name: defer
timing: 0.024 s
source
defer_parent <- function(expr, priority = c("first", "last")) {
  defer(expr, parent.frame(2), priority = priority)
}
R/defer.R:121

<statement> typed

timing: 0.013 s
source
the$global_exits <- list()
R/defer.R:230
R/devices.R

<statement> typed

timing: 0.000 s
source
NULL
R/devices.R:34

dev_close untypeabletyped

unbound variable (line 186)
unbound: grDevices::dev.prev — a name the prelude does not declare
error detail
name: grDevices::dev.prev
gradual mode: typed
((which: any) -> any)<>
timing: 0.004 s
source
dev_close <- function(which) {
  prev <- grDevices::dev.prev(which)
  grDevices::dev.off(which)

  # No devices active
  if (prev != which) {
    grDevices::dev.set(prev)
  }

  prev
}
R/devices.R:185

defer_dev_close untypeable

unbound variable (line 177)
unbound: grDevices::dev.cur — a name the prelude does not declare
error detail
name: grDevices::dev.cur
timing: 0.002 s
source
defer_dev_close <- function(frame) {
  cur <- grDevices::dev.cur()
  defer(dev_close(cur), envir = frame)

  # Note that unlike typical `local_` functions we return the current device
  # rather than the old one
  invisible(cur)
}
R/devices.R:176

local_bmp untypeabletyped

unbound variable (line 46)
unbound: grDevices::bmp — a name the prelude does not declare
error detail
name: grDevices::bmp
gradual mode: typed
((new: any, ...: any, .local_envir: any?) -> any)<>
timing: 0.008 s
source
local_bmp <- function(new, ..., .local_envir = parent.frame()) {
  grDevices::bmp(new, ...)
  defer_dev_close(.local_envir)
}
R/devices.R:45

with_bmp untypeabletyped

unbound variable (line 39)
unbound: local_bmp — one of the package’s own names, itself untyped
error detail
name: local_bmp
gradual mode: typed
∀'a. ((new: any, code: 'a, ...: any) -> 'a)<>
timing: 0.008 s
source
with_bmp <- function(new, code, ...) {
  local_bmp(new, ...)
  code
}
R/devices.R:38

local_cairo_pdf untypeabletyped

unbound variable (line 60)
unbound: grDevices::cairo_pdf — a name the prelude does not declare
error detail
name: grDevices::cairo_pdf
gradual mode: typed
((new: any, ...: any, .local_envir: any?) -> any)<>
timing: 0.008 s
source
local_cairo_pdf <- function(new, ..., .local_envir = parent.frame()) {
  grDevices::cairo_pdf(new, ...)
  defer_dev_close(.local_envir)
}
R/devices.R:59

with_cairo_pdf untypeabletyped

unbound variable (line 53)
unbound: local_cairo_pdf — one of the package’s own names, itself untyped
error detail
name: local_cairo_pdf
gradual mode: typed
∀'a. ((new: any, code: 'a, ...: any) -> 'a)<>
timing: 0.007 s
source
with_cairo_pdf <- function(new, code, ...) {
  local_cairo_pdf(new, ...)
  code
}
R/devices.R:52

local_cairo_ps untypeabletyped

unbound variable (line 74)
unbound: grDevices::cairo_ps — a name the prelude does not declare
error detail
name: grDevices::cairo_ps
gradual mode: typed
((new: any, ...: any, .local_envir: any?) -> any)<>
timing: 0.008 s
source
local_cairo_ps <- function(new, ..., .local_envir = parent.frame()) {
  grDevices::cairo_ps(new, ...)
  defer_dev_close(.local_envir)
}
R/devices.R:73

with_cairo_ps untypeabletyped

unbound variable (line 67)
unbound: local_cairo_ps — one of the package’s own names, itself untyped
error detail
name: local_cairo_ps
gradual mode: typed
∀'a. ((new: any, code: 'a, ...: any) -> 'a)<>
timing: 0.007 s
source
with_cairo_ps <- function(new, code, ...) {
  local_cairo_ps(new, ...)
  code
}
R/devices.R:66

local_pdf untypeabletyped

unbound variable (line 88)
unbound: grDevices::pdf — a name the prelude does not declare
error detail
name: grDevices::pdf
gradual mode: typed
((new: any, ...: any, .local_envir: any?) -> any)<>
timing: 0.008 s
source
local_pdf <- function(new, ..., .local_envir = parent.frame()) {
  grDevices::pdf(new, ...)
  defer_dev_close(.local_envir)
}
R/devices.R:87

with_pdf untypeabletyped

unbound variable (line 81)
unbound: local_pdf — one of the package’s own names, itself untyped
error detail
name: local_pdf
gradual mode: typed
∀'a. ((new: any, code: 'a, ...: any) -> 'a)<>
timing: 0.007 s
source
with_pdf <- function(new, code, ...) {
  local_pdf(new, ...)
  code
}
R/devices.R:80

local_postscript untypeabletyped

unbound variable (line 102)
unbound: grDevices::postscript — a name the prelude does not declare
error detail
name: grDevices::postscript
gradual mode: typed
((new: any, ...: any, .local_envir: any?) -> any)<>
timing: 0.008 s
source
local_postscript <- function(new, ..., .local_envir = parent.frame()) {
  grDevices::postscript(new, ...)
  defer_dev_close(.local_envir)
}
R/devices.R:101

with_postscript untypeabletyped

unbound variable (line 95)
unbound: local_postscript — one of the package’s own names, itself untyped
error detail
name: local_postscript
gradual mode: typed
∀'a. ((new: any, code: 'a, ...: any) -> 'a)<>
timing: 0.007 s
source
with_postscript <- function(new, code, ...) {
  local_postscript(new, ...)
  code
}
R/devices.R:94

local_svg untypeabletyped

unbound variable (line 116)
unbound: grDevices::svg — a name the prelude does not declare
error detail
name: grDevices::svg
gradual mode: typed
((new: any, ...: any, .local_envir: any?) -> any)<>
timing: 0.008 s
source
local_svg <- function(new, ..., .local_envir = parent.frame()) {
  grDevices::svg(new, ...)
  defer_dev_close(.local_envir)
}
R/devices.R:115

with_svg untypeabletyped

unbound variable (line 109)
unbound: local_svg — one of the package’s own names, itself untyped
error detail
name: local_svg
gradual mode: typed
∀'a. ((new: any, code: 'a, ...: any) -> 'a)<>
timing: 0.007 s
source
with_svg <- function(new, code, ...) {
  local_svg(new, ...)
  code
}
R/devices.R:108

local_tiff untypeabletyped

unbound variable (line 130)
unbound: grDevices::tiff — a name the prelude does not declare
error detail
name: grDevices::tiff
gradual mode: typed
((new: any, ...: any, .local_envir: any?) -> any)<>
timing: 0.008 s
source
local_tiff <- function(new, ..., .local_envir = parent.frame()) {
  grDevices::tiff(new, ...)
  defer_dev_close(.local_envir)
}
R/devices.R:129

with_tiff untypeabletyped

unbound variable (line 123)
unbound: local_tiff — one of the package’s own names, itself untyped
error detail
name: local_tiff
gradual mode: typed
∀'a. ((new: any, code: 'a, ...: any) -> 'a)<>
timing: 0.007 s
source
with_tiff <- function(new, code, ...) {
  local_tiff(new, ...)
  code
}
R/devices.R:122

local_xfig untypeabletyped

unbound variable (line 144)
unbound: grDevices::xfig — a name the prelude does not declare
error detail
name: grDevices::xfig
gradual mode: typed
((new: any, ...: any, .local_envir: any?) -> any)<>
timing: 0.008 s
source
local_xfig <- function(new, ..., .local_envir = parent.frame()) {
  grDevices::xfig(new, ...)
  defer_dev_close(.local_envir)
}
R/devices.R:143

with_xfig untypeabletyped

unbound variable (line 137)
unbound: local_xfig — one of the package’s own names, itself untyped
error detail
name: local_xfig
gradual mode: typed
∀'a. ((new: any, code: 'a, ...: any) -> 'a)<>
timing: 0.007 s
source
with_xfig <- function(new, code, ...) {
  local_xfig(new, ...)
  code
}
R/devices.R:136

local_png untypeabletyped

unbound variable (line 158)
unbound: grDevices::png — a name the prelude does not declare
error detail
name: grDevices::png
gradual mode: typed
((new: any, ...: any, .local_envir: any?) -> any)<>
timing: 0.008 s
source
local_png <- function(new, ..., .local_envir = parent.frame()) {
  grDevices::png(new, ...)
  defer_dev_close(.local_envir)
}
R/devices.R:157

with_png untypeabletyped

unbound variable (line 151)
unbound: local_png — one of the package’s own names, itself untyped
error detail
name: local_png
gradual mode: typed
∀'a. ((new: any, code: 'a, ...: any) -> 'a)<>
timing: 0.007 s
source
with_png <- function(new, code, ...) {
  local_png(new, ...)
  code
}
R/devices.R:150

local_jpeg untypeabletyped

unbound variable (line 172)
unbound: grDevices::jpeg — a name the prelude does not declare
error detail
name: grDevices::jpeg
gradual mode: typed
((new: any, ...: any, .local_envir: any?) -> any)<>
timing: 0.008 s
source
local_jpeg <- function(new, ..., .local_envir = parent.frame()) {
  grDevices::jpeg(new, ...)
  defer_dev_close(.local_envir)
}
R/devices.R:171

with_jpeg untypeabletyped

unbound variable (line 165)
unbound: local_jpeg — one of the package’s own names, itself untyped
error detail
name: local_jpeg
gradual mode: typed
∀'a. ((new: any, code: 'a, ...: any) -> 'a)<>
timing: 0.007 s
source
with_jpeg <- function(new, code, ...) {
  local_jpeg(new, ...)
  code
}
R/devices.R:164
R/dir.R

<statement> typed

timing: 0.000 s
source
NULL
R/dir.R:2

with_dir untypeabletyped

unbound variable (line 19)
unbound: with_ — one of the package’s own names, itself untyped
error detail
name: with_
gradual mode: typed
any
timing: 0.007 s
source
with_dir <- with_(setwd)
R/dir.R:19

local_dir untypeabletyped

unbound variable (line 23)
unbound: local_ — one of the package’s own names, itself untyped
error detail
name: local_
gradual mode: typed
any
timing: 0.001 s
source
local_dir <- local_(setwd)
R/dir.R:23
R/file.R

with_file untypeabletyped

unbound variable (line 22)
unbound: unlink — a name the prelude does not declare
error detail
name: unlink
gradual mode: typed
∀'a. ((file: 'a & vec<~@"[", ...>, code: any) -> 'a)<>
timing: 0.088 s
source
with_file <- function(file, code) {
  file_nms <- names2(file)
  unnamed <- file_nms == ""
  file_nms[unnamed] <- as.character(file[unnamed])
  on.exit(unlink(file_nms, recursive = TRUE))
  force(code)

  invisible(file)
}
R/file.R:18

local_file untypeable

unbound variable (line 31)
unbound: utils::modifyList — a name the prelude does not declare
error detail
name: utils::modifyList
timing: 0.100 s
source
local_file <- function(.file, ..., .local_envir = parent.frame()) {
  .file <- utils::modifyList(as.list(.file), list(...))
  .file <- as_character(.file)

  file_nms <- names2(.file)
  unnamed <- file_nms == ""
  file_nms[unnamed] <- as.character(.file[unnamed])
  defer(unlink(file_nms, recursive = TRUE), envir = .local_envir)

  invisible(.file)
}
R/file.R:30
R/tempfile.R

with_tempfile untypeabletyped

unbound variable (line 43)
unbound: .Deprecated — a name the prelude does not declare
error detail
name: .Deprecated
gradual mode: typed
((new: list | vec, code: any, envir: env?, .local_envir: env?, pattern: vec?, tmpdir: vec?, fileext: vec?) -> any)<>
timing: 0.126 s
source
with_tempfile <- function(
  new,
  code,
  envir = parent.frame(),
  .local_envir = parent.frame(),
  pattern = "file",
  tmpdir = tempdir(),
  fileext = ""
) {
  if (!missing(envir)) {
    .Deprecated(
      msg = "`envir` argument of with_tempfile() is deprecated.\n  Use `with_tempfile(.local_envir=)` instead."
    )
    .local_envir <- envir
  }
  env <- new.env(parent = .local_envir)
  for (f in new) {
    assign(
      f,
      tempfile(pattern = pattern, tmpdir = tmpdir, fileext = fileext),
      envir = env
    )
  }
  on.exit(unlink(mget(new, envir = env), recursive = TRUE))
  eval(substitute(code), envir = env)
}
R/tempfile.R:33

local_tempfile untypeable

unbound variable (line 75)
unbound: .Deprecated — a name the prelude does not declare
error detail
name: .Deprecated
timing: 0.162 s
source
local_tempfile <- function(
  new = NULL,
  lines = NULL,
  envir = parent.frame(),
  .local_envir = parent.frame(),
  pattern = "file",
  tmpdir = tempdir(),
  fileext = ""
) {
  if (!missing(envir)) {
    .Deprecated(
      msg = "`envir` argument of local_tempfile() is deprecated.\n  Use `local_tempfile(.local_envir=)` instead."
    )
    .local_envir <- envir
  }
  if (is.null(new)) {
    path <- tempfile(pattern = pattern, tmpdir = tmpdir, fileext = fileext)
    if (!is.null(lines)) {
      con <- file(path, open = "wb", encoding = "native.enc")
      defer(close(con))

      writeLines(enc2utf8(lines), con, useBytes = TRUE)
    }

    defer(unlink(path, recursive = TRUE), envir = .local_envir)
    return(path)
  }

  .Deprecated(
    msg = "`new` argument of local_tempfile() is deprecated.\n  Use `path <- local_tempfile()` instead."
  )

  for (f in new) {
    assign(
      f,
      tempfile(pattern = pattern, tmpdir = tmpdir, fileext = fileext),
      envir = .local_envir
    )
  }
  defer(
    unlink(mget(new, envir = .local_envir), recursive = TRUE),
    envir = .local_envir
  )
}
R/tempfile.R:65

with_tempdir untypeabletyped

unbound variable (line 126)
unbound: dir.create — a name the prelude does not declare
error detail
name: dir.create
gradual mode: typed
((code: any, clean: LGL?, pattern: vec?, tmpdir: vec?, fileext: vec?) -> any)<>
timing: 0.184 s
source
with_tempdir <- function(
  code,
  clean = TRUE,
  pattern = "file",
  tmpdir = tempdir(),
  fileext = ""
) {
  if (length(clean) > 1 || !is.logical(clean)) {
    stop("`clean` must be a single TRUE or FALSE", call. = FALSE)
  }

  tmp <- tempfile(pattern = pattern, tmpdir = tmpdir, fileext = fileext)

  dir.create(tmp)
  if (clean) {
    on.exit(unlink(tmp, recursive = TRUE), add = TRUE)
  }
  withr::with_dir(tmp, code)
}
R/tempfile.R:113

local_tempdir untypeable

unbound variable (line 148)
unbound: dir.create — a name the prelude does not declare
error detail
name: dir.create
timing: 0.198 s
source
local_tempdir <- function(
  pattern = "file",
  tmpdir = tempdir(),
  fileext = "",
  .local_envir = parent.frame(),
  clean = TRUE
) {
  if (length(clean) > 1 || !is.logical(clean)) {
    stop("`clean` must be a single TRUE or FALSE", call. = FALSE)
  }

  path <- tempfile(pattern = pattern, tmpdir = tmpdir, fileext = fileext)

  dir.create(path, recursive = TRUE)

  if (isTRUE(clean)) {
    defer(unlink(path, recursive = TRUE), envir = .local_envir)
  }

  path
}
R/tempfile.R:135
R/language.R

check_language_envvar typed accepts outside

((var: vec) -> CHR1<> | null)<>
timing: 0.137 s
fuzzing: 8 inside (1 ok, 7 error type) · 8 outside (4 rejected, 4 accepted)

Accepted outside the domain var: 4

parameterchangecallreturned
varwrapcheck_language_envvar("var" = list(c(complex(real = 0, imaginary = 0), complex(real = 0, imaginary = 0))))null
varwrapcheck_language_envvar("var" = list(Inf))null
varwrapcheck_language_envvar("var" = list(logical(0)))null
varwrapcheck_language_envvar("var" = list(c(Inf, Inf, -Inf, -2147483647, 0)))null

Other calls inside the domain

callverdicterror
check_language_envvar("var" = c(complex(real = 0, imaginary = 0), complex(real = 0, imaginary = 0)))error_typebase::if: the condition has length > 1
check_language_envvar("var" = raw(0))error_typebase::if: the condition has length > 1
check_language_envvar("var" = c(NA_complex_, complex(real = 0, imaginary = 0), NA_complex_, complex(real = 0, imaginary = 0), complex(real = 0, imaginary = 0)))error_typebase::if: the condition has length > 1
check_language_envvar("var" = c(-2147483647, -1))error_typebase::if: the condition has length > 1
check_language_envvar("var" = logical(0))error_typebase::if: the condition has length > 1
check_language_envvar("var" = c(Inf, Inf, -Inf, -2147483647, 0))error_typebase::if: the condition has length > 1
and 1 more
source
check_language_envvar <- function(var) {
  if (Sys.getenv(var) %in% c("C", "C.UTF-8")) {
    warning(sprintf(
      "Changing language has no effect when envvar %s='%s'",
      var,
      Sys.getenv(var)
    ))
  }
}
R/language.R:71

has_nls typed fuzz ok

(() -> LGL1<>)<>
timing: 0.018 s
fuzzing: 1 inside (1 ok) · 1 outside (1 rejected)
source
has_nls <- function() capabilities("NLS")[[1]]
R/language.R:81

reset_gettext_cache untypeabletyped

unbound variable (line 68)
unbound: local_tempdir — one of the package’s own names, itself untyped
error detail
name: local_tempdir
gradual mode: typed
(() -> any)<>
timing: 0.002 s
source
reset_gettext_cache <- function() {
  bindtextdomain("reset", local_tempdir())
}
R/language.R:67

local_language typed empty return any: .local_envir

((lang: ~CHR, .local_envir: any?) -> empty)<>
timing: 0.126 s
source
local_language <- function(lang, .local_envir = parent.frame()) {
  if (!is.character(lang) || length(lang) != 1) {
    stop("`lang` must be a string")
  }

  # Reset a first time in case the cache was populated beforehand
  reset_gettext_cache()

  # Reset afterwards to clear any translation we might cache
  defer(reset_gettext_cache(), envir = .local_envir)

  # https://stackoverflow.com/questions/6152321
  lang <- gsub("-", "_", lang, fixed = TRUE)

  # Only warn if setting `LANGUAGE` to something other than `"C"` (#254)
  if (lang != "C") {
    if (!has_nls()) {
      warning("Changing language has no effect when R installed without NLS")
    }

    # > Note: The variable LANGUAGE is ignored if the locale is set to ‘C’.
    # > In other words, you have to first enable localization, by setting LANG
    # > (or LC_ALL) to a value other than ‘C’, before you can use a language
    # > priority list through the LANGUAGE variable.
    # --- https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html

    # `LC_ALL` has precedence over `LANG`. Check for the latter if the
    # former is unset, otherwise check for the former.
    if (Sys.getenv("LC_ALL", "") == "") {
      # Causes too many failures because testthat sets `LANG` to "C"
      # check_language_envvar("LANG")
    } else {
      check_language_envvar("LC_ALL")
    }
  }

  local_envvar(LANGUAGE = lang, .local_envir = .local_envir)

  invisible()
}
R/language.R:23

with_language typed empty return any: code

((lang: ~CHR, code: any) -> empty)<>
timing: 0.025 s
source
with_language <- function(lang, code) {
  local_language(lang)
  code
}
R/language.R:16
R/libpaths.R

set_libpaths untypeabletyped

unbound variable (line 10)
unbound: merge_new — one of the package’s own names, itself untyped
error detail
name: merge_new
gradual mode: typed
((paths: vec | null, action: any?) -> CHR<>)<>
timing: 0.057 s
source
set_libpaths <- function(paths, action = "replace") {
  paths <- as_character(paths)
  paths <- normalizePath(paths, mustWork = TRUE)

  old <- .libPaths()
  paths <- merge_new(old, paths, action)

  .libPaths(paths)
  invisible(old)
}
R/libpaths.R:5

get_libpaths typed fuzz ok

((...: any) -> CHR<>)<>
timing: 0.007 s
fuzzing: 8 inside (8 ok) · 0 outside (none)
source
get_libpaths <- function(...) {
  .libPaths()
}
R/libpaths.R:16

set_temp_libpath untypeabletyped

unbound variable (line 22)
unbound: dir.create — a name the prelude does not declare
error detail
name: dir.create
gradual mode: typed
((action: any?) -> CHR<>)<>
timing: 0.006 s
source
set_temp_libpath <- function(action = "prefix") {
  paths <- tempfile("temp_libpath")
  dir.create(paths)
  set_libpaths(paths, action = action)
}
R/libpaths.R:20

with_libpaths untypeabletyped

unbound variable (line 44)
unbound: set_libpaths — one of the package’s own names, itself untyped
error detail
name: set_libpaths
gradual mode: typed
any
timing: 0.008 s
source
with_libpaths <- with_(set_libpaths, .libPaths, get = get_libpaths)
R/libpaths.R:44

local_libpaths untypeabletyped

unbound variable (line 48)
unbound: set_libpaths — one of the package’s own names, itself untyped
error detail
name: set_libpaths
gradual mode: typed
any
timing: 0.001 s
source
local_libpaths <- local_(set_libpaths, .libPaths, get = get_libpaths)
R/libpaths.R:48

with_temp_libpaths untypeabletyped

unbound variable (line 60)
unbound: set_temp_libpath — one of the package’s own names, itself untyped
error detail
name: set_temp_libpath
gradual mode: typed
any
timing: 0.001 s
source
with_temp_libpaths <- with_(
  set_temp_libpath,
  .libPaths,
  get = get_libpaths,
  new = FALSE
)
R/libpaths.R:59

local_temp_libpaths untypeabletyped

unbound variable (line 69)
unbound: set_temp_libpath — one of the package’s own names, itself untyped
error detail
name: set_temp_libpath
gradual mode: typed
any
timing: 0.001 s
source
local_temp_libpaths <- local_(
  set_temp_libpath,
  .libPaths,
  get = get_libpaths,
  new = FALSE
)
R/libpaths.R:68
R/makevars.R

<statement> typed

timing: 0.000 s
source
NULL
R/makevars.R:2

set_makevars skipped

error detail
File "Rsem/lang/PAst.ml", line 210, characters 14-20: Assertion failed
timing: 0.000 s
source
set_makevars <- function(
  variables,
  old_path = makevars_user(),
  new_path = tempfile(),
  assignment = c("=", ":=", "?=", "+=")
) {
  if (length(variables) == 0) {
    return()
  }
  stopifnot(is.named(variables))

  assignment <- match.arg(assignment)

  old <- NULL
  if (length(old_path) == 1 && file.exists(old_path)) {
    lines <- readLines(old_path)
    old <- lines
    for (var in names(variables)) {
      loc <- grep(
        paste(c("^[[:space:]]*", var, "[[:space:]]*", "="), collapse = ""),
        lines
      )
      if (length(loc) == 0) {
        lines <- append(lines, paste(sep = assignment, var, variables[var]))
      } else if (length(loc) == 1) {
        lines[loc] <- paste(sep = assignment, var, variables[var])
      } else {
        stop(
          "Multiple results for ",
          var,
          " found, something is wrong.",
          .call = FALSE
        )
      }
    }
  } else {
    lines <- paste(names(variables), variables, sep = assignment)
  }

  if (!identical(old, lines)) {
    writeLines(con = new_path, lines)
  }

  old
}
R/makevars.R:21

with_makevars untypeable

unbound variable (line 92)
unbound: makevars_user — one of the package’s own names, itself untyped
error detail
name: makevars_user
timing: 0.024 s
source
with_makevars <- function(
  new,
  code,
  path = makevars_user(),
  assignment = c("=", ":=", "?=", "+=")
) {
  assignment <- match.arg(assignment)
  makevars_file <- tempfile()
  on.exit(unlink(makevars_file), add = TRUE)
  force(path)
  with_envvar(c(R_MAKEVARS_USER = makevars_file), {
    set_makevars(new, path, makevars_file, assignment = assignment)
    force(code)
  })
}
R/makevars.R:89

local_makevars untypeable

unbound variable (line 110)
unbound: makevars_user — one of the package’s own names, itself untyped
error detail
name: makevars_user
timing: 0.021 s
source
local_makevars <- function(
  .new = list(),
  ...,
  .path = makevars_user(),
  .assignment = c("=", ":=", "?=", "+="),
  .local_envir = parent.frame()
) {
  .new <- utils::modifyList(as.list(.new), list(...))
  .new <- as_character(.new)

  .assignment <- match.arg(.assignment)
  makevars_file <- tempfile()
  defer(unlink(makevars_file), envir = .local_envir)
  force(.path)
  local_envvar(c(R_MAKEVARS_USER = makevars_file), .local_envir = .local_envir)
  invisible(set_makevars(.new, .path, makevars_file, assignment = .assignment))
}
R/makevars.R:107
R/namespace.R

with_package untypeable

unbound variable (line 33)
unbound: .packages — a name the prelude does not declare
error detail
name: .packages
timing: 0.202 s
source
with_package <- function(
  package,
  code,
  pos = 2,
  lib.loc = NULL,
  character.only = TRUE,
  logical.return = FALSE,
  warn.conflicts = FALSE,
  quietly = TRUE,
  verbose = getOption("verbose")
) {
  # Only try to attach (and detach) the package if it is not already attached.
  if (!(package %in% .packages())) {
    suppressPackageStartupMessages(
      (get("library"))(
        package,
        pos = pos,
        lib.loc = lib.loc,
        character.only = character.only,
        logical.return = logical.return,
        warn.conflicts = warn.conflicts,
        quietly = quietly,
        verbose = verbose
      )
    )

    on.exit(detach(paste0("package:", package), character.only = TRUE))
  }

  force(code)
}
R/namespace.R:21

local_package untypeable

untypeable projection (line 67)
error detail
argument: any
argument may be: new.env()
timing: 0.204 s
source
local_package <- function(
  package,
  pos = 2,
  lib.loc = NULL,
  character.only = TRUE,
  logical.return = FALSE,
  warn.conflicts = FALSE,
  quietly = TRUE,
  verbose = getOption("verbose"),
  .local_envir = parent.frame()
) {
  suppressPackageStartupMessages(
    (get("library"))(
      package,
      pos = pos,
      lib.loc = lib.loc,
      character.only = character.only,
      logical.return = logical.return,
      warn.conflicts = warn.conflicts,
      quietly = quietly,
      verbose = verbose
    )
  )

  defer(
    detach(paste0("package:", package), character.only = TRUE),
    envir = .local_envir
  )
}
R/namespace.R:55

with_namespace untypeable

untypeable projection (line 90)
error detail
argument: any
argument may be: new.env()
timing: 0.032 s
source
with_namespace <- function(package, code, warn.conflicts = FALSE) {
  ns <- asNamespace(package)
  name <- format(ns)
  (get("attach"))(ns, name = name, warn.conflicts = warn.conflicts)
  on.exit(detach(name, character.only = TRUE))
  force(code)
}
R/namespace.R:87

local_namespace untypeable

untypeable projection (line 104)
error detail
argument: any
argument may be: new.env()
timing: 0.035 s
source
local_namespace <- function(
  package,
  .local_envir = parent.frame(),
  warn.conflicts = FALSE
) {
  ns <- asNamespace(package)
  name <- format(ns)
  (get("attach"))(ns, name = name, warn.conflicts = warn.conflicts)
  defer(detach(name, character.only = TRUE), envir = .local_envir)
}
R/namespace.R:97

with_environment untypeable

untypeable projection (line 118)
error detail
argument: any
argument may be: new.env()
timing: 0.112 s
source
with_environment <- function(
  env,
  code,
  pos = 2L,
  name = format(env),
  warn.conflicts = FALSE
) {
  (get("attach"))(env, name = name, pos = pos, warn.conflicts = warn.conflicts)
  on.exit(detach(name, character.only = TRUE))
  force(code)
}
R/namespace.R:111

local_environment untypeable

untypeable projection (line 132)
error detail
argument: any
argument may be: new.env()
timing: 0.117 s
source
local_environment <- function(
  env,
  pos = 2L,
  name = format(env),
  warn.conflicts = FALSE,
  .local_envir = parent.frame()
) {
  (get("attach"))(env, name = name, pos = pos, warn.conflicts = warn.conflicts)
  defer(detach(name, character.only = TRUE), envir = .local_envir)
}
R/namespace.R:125
R/par.R

<statement> typed

timing: 0.000 s
source
NULL
R/par.R:2

get_par untypeabletyped

unbound variable (line 10)
unbound: graphics::par — a name the prelude does not declare
error detail
name: graphics::par
gradual mode: typed
((...: any) -> any)<>
timing: 0.128 s
source
get_par <- function(...) {
  new <- auto_splice(list(...))
  if (length(new) == 0) {
    # Only retrieve settable values
    out <- graphics::par(no.readonly = TRUE)
  } else {
    out <- do.call(graphics::par, as.list(names(new)))
  }

  # `par()` doesn't wrap in a list if input is length 1
  if (length(new) == 1) {
    out <- list(out)
    names(out) <- names(new)
  }

  out
}
R/par.R:6

<statement> typed

timing: 0.000 s
source
formals(get_par) <- formals(graphics::par)
R/par.R:26

with_par untypeabletyped

unbound variable (line 51)
unbound: graphics::par — a name the prelude does not declare
error detail
name: graphics::par
gradual mode: typed
any
timing: 0.000 s
source
with_par <- with_(graphics::par, get = get_par)
R/par.R:51

local_par untypeabletyped

unbound variable (line 55)
unbound: graphics::par — a name the prelude does not declare
error detail
name: graphics::par
gradual mode: typed
any
timing: 0.000 s
source
local_par <- local_(graphics::par, get = get_par, dots = TRUE)
R/par.R:55
R/path.R

get_path typed fuzz ok

((...: any) -> CHR<>)<>
timing: 0.036 s
fuzzing: 7 inside (7 ok) · 0 outside (none)
source
get_path <- function(...) {
  strsplit(Sys.getenv("PATH"), .Platform$path.sep)[[1]]
}
R/path.R:3

set_path untypeabletyped

unbound variable (line 14)
unbound: merge_new — one of the package’s own names, itself untyped
error detail
name: merge_new
gradual mode: typed
((path: vec | null, action: (vec | null)?) -> CHR<>)<>
timing: 0.084 s
source
set_path <- function(path, action = c("prefix", "suffix", "replace")) {
  action <- match.arg(action)

  path <- as_character(path)
  path <- normalizePath(path, mustWork = FALSE)

  old <- get_path()
  path <- merge_new(old, path, action)

  path <- paste(path, collapse = .Platform$path.sep)
  Sys.setenv(PATH = path)
  invisible(old)
}
R/path.R:7

with_path untypeabletyped

unbound variable (line 39)
unbound: set_path — one of the package’s own names, itself untyped
error detail
name: set_path
gradual mode: typed
any
timing: 0.001 s
source
with_path <- with_(
  set_path,
  reset = function(old) set_path(old, "replace"),
  get = get_path
)
R/path.R:38

local_path untypeabletyped

unbound variable (line 47)
unbound: set_path — one of the package’s own names, itself untyped
error detail
name: set_path
gradual mode: typed
any
timing: 0.001 s
source
local_path <- local_(
  set_path,
  reset = function(old) set_path(old, "replace"),
  get = get_path
)
R/path.R:46
R/rng.R

restore_rng_kind untypeabletyped

unbound variable (line 68)
unbound: RNGkind — a name the prelude does not declare
error detail
name: RNGkind
gradual mode: typed
(((kind: <@"[[", ...>) | (kind: list<~@"[[", ...>) | (kind: vec<~@"[[", ...>) -> null) & ((kind: { }<~@"[[", ...>) -> empty))<>
timing: 0.133 s
source
restore_rng_kind <- function(kind) {
  # Silence static analysis linting about `RNGkind()` signature on old
  # R versions
  RNGkind <- get("RNGkind")

  RNGkind(kind[[1]], normal.kind = kind[[2]])

  # Within a `local_rng_version("3.5.0")`, we restore to `"Rounding"`,
  # which causes a warning. See https://github.com/r-lib/withr/issues/167
  sample_kind <- kind[[3]]
  if (identical(sample_kind, "Rounding")) {
    suppressWarnings(
      RNGkind(sample.kind = sample_kind)
    )
  } else {
    RNGkind(sample.kind = sample_kind)
  }

  NULL
}
R/rng.R:63

with_rng_version untypeabletyped

unbound variable (line 32)
unbound: RNGkind — a name the prelude does not declare
error detail
name: RNGkind
gradual mode: typed
∀'a. ((version: any, code: 'a) -> 'a)<>
timing: 0.004 s
source
with_rng_version <- function(version, code) {
  old <- RNGkind()
  on.exit(restore_rng_kind(old), add = TRUE)
  suppressWarnings(RNGversion(version))
  code
}
R/rng.R:31

local_rng_version untypeable

unbound variable (line 57)
unbound: RNGkind — a name the prelude does not declare
error detail
name: RNGkind
timing: 0.006 s
source
local_rng_version <- function(version, .local_envir = parent.frame()) {
  old <- RNGkind()
  defer(restore_rng_kind(old), envir = .local_envir)
  suppressWarnings(RNGversion(version))
  old
}
R/rng.R:56
R/seed.R

set_seed untypeabletyped

unbound variable (line 121)
unbound: restore_rng_kind — one of the package’s own names, itself untyped
error detail
name: restore_rng_kind
gradual mode: typed
(((seed: { rng_kind: { }<~@"[[", ...>, any }) -> empty) & ((seed: { seed: null, rng_kind: list<~@"[[", ...> | vec<~@"[[", ...> | <@"[[", ...>, random_seed: any, any }) | (seed: { seed: ~null, rng_kind: list<~@"[[", ...> | vec<~@"[[", ...> | <@"[[", ...>, any }) -> any))<>
timing: 0.036 s
source
set_seed <- function(seed) {
  restore_rng_kind(seed$rng_kind)

  if (is.null(seed$seed)) {
    assign(".Random.seed", seed$random_seed, globalenv())
  } else {
    set.seed(seed$seed)
  }
}
R/seed.R:120

has_seed untypeabletyped

unbound variable (line 99)
unbound: exists — a name the prelude does not declare
error detail
name: exists
gradual mode: typed
(() -> any)<>
timing: 0.002 s
source
has_seed <- function() {
  exists(".Random.seed", globalenv(), mode = "integer", inherits = FALSE)
}
R/seed.R:98

get_seed untypeable

unbound variable (line 106)
unbound: has_seed — one of the package’s own names, itself untyped
error detail
name: has_seed
timing: 0.012 s
source
get_seed <- function() {
  # Return `NULL` (rather than a list with `random_seed = NULL`) when no
  # seed exists. Callers branch on `is.null()` to decide whether to remove
  # `.Random.seed` on exit instead of assigning `NULL` to it.
  if (!has_seed()) {
    return(NULL)
  }
  list(
    random_seed = get0(
      ".Random.seed",
      globalenv(),
      mode = "integer",
      inherits = FALSE
    ),
    rng_kind = RNGkind()
  )
}
R/seed.R:102

rm_seed untypeable

unbound variable (line 131)
unbound: has_seed — one of the package’s own names, itself untyped
error detail
name: has_seed
timing: 0.011 s
source
rm_seed <- function() {
  if (!has_seed()) {
    return(NULL)
  }
  set.seed(seed = NULL) # also reset Normal RNG state (cf. #162)
  rm(".Random.seed", envir = globalenv())
}
R/seed.R:130

with_preserve_seed untypeabletyped

unbound variable (line 71)
unbound: get_seed — one of the package’s own names, itself untyped
error detail
name: get_seed
gradual mode: typed
∀'a. ((code: 'a) -> 'a)<>
timing: 0.008 s
source
with_preserve_seed <- function(code) {
  old_seed <- get_seed()
  if (is.null(old_seed)) {
    on.exit(rm_seed(), add = TRUE)
  } else {
    on.exit(set_seed(old_seed), add = TRUE)
  }

  code
}
R/seed.R:70

with_seed untypeabletyped

unbound variable (line 33)
unbound: set_seed — one of the package’s own names, itself untyped
error detail
name: set_seed
gradual mode: typed
∀'a. ((seed: ~null, code: 'a, .rng_kind: any?, .rng_normal_kind: any?, .rng_sample_kind: any?) -> 'a)<>
timing: 0.079 s
source
with_seed <- function(
  seed,
  code,
  .rng_kind = NULL,
  .rng_normal_kind = NULL,
  .rng_sample_kind = NULL
) {
  force(seed)
  rng_kind <- list(.rng_kind, .rng_normal_kind, .rng_sample_kind)

  with_preserve_seed({
    set_seed(list(seed = seed, rng_kind = rng_kind))
    code
  })
}
R/seed.R:22

local_seed skipped

error detail
Failure("Unsupported positional argument after a named one.")
timing: 0.000 s
source
local_seed <- function(
  seed,
  .local_envir = parent.frame(),
  .rng_kind = NULL,
  .rng_normal_kind = NULL,
  .rng_sample_kind = NULL
) {
  old_seed <- get_seed()

  defer(envir = .local_envir, {
    if (is.null(old_seed)) {
      rm_seed()
    } else {
      set_seed(old_seed)
    }
  })

  rng_kind <- list(.rng_kind, .rng_normal_kind, .rng_sample_kind)
  set_seed(list(seed = seed, rng_kind = rng_kind))

  # FIXME
  invisible(seed)
}
R/seed.R:40

local_preserve_seed untypeable

unbound variable (line 84)
unbound: get_seed — one of the package’s own names, itself untyped
error detail
name: get_seed
timing: 0.011 s
source
local_preserve_seed <- function(.local_envir = parent.frame()) {
  old_seed <- get_seed()

  defer(
    if (is.null(old_seed)) {
      rm_seed()
    } else {
      set_seed(old_seed)
    },
    envir = .local_envir
  )

  invisible(old_seed)
}
R/seed.R:83
R/wrap.R

wrap untypeabletyped

unbound variable (line 2)
unbound: formals — a name the prelude does not declare
error detail
name: formals
gradual mode: typed
((f: any, pre: any, post: any, envir: any?) -> any)<>
timing: 0.059 s
source
wrap <- function(f, pre, post, envir = parent.frame()) {
  fmls <- formals(f)

  # called pass all extra formals on
  called_fmls <- setNames(lapply(names(fmls), as.symbol), names(fmls))

  f_call <- as.call(c(substitute(f), called_fmls))
  pre <- substitute(pre)
  post <- substitute(post)

  fun <- eval(bquote(
    function(args) {
      .(pre)
      .retval <- .(f_call)
      .(post)
    },
    as.environment(list(f_call = f_call, pre = pre, post = post))
  ))

  # substitute does not work on arguments, so we need to fix them manually
  formals(fun) <- fmls

  environment(fun) <- envir

  fun
}
R/wrap.R:1
R/sink.R

output_sink typed any: file accepts outside

((file: any?, append: lgl1?, split: lgl1?) -> null)<>
timing: 0.064 s
fuzzing: 8 inside (3 ok, 5 error type) · 8 outside (5 rejected, 1 accepted, 2 not forced)

Accepted outside the domain split: 1

parameterchangecallreturned
splitlength:2output_sink("split" = as.raw(c(0, 0)))null

Other calls inside the domain

callverdicterror
output_sink(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), "append" = NA)error_typebase::sink: 'file' must be NULL, a connection or a character string
output_sink(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), as.raw(c(255)), NA)error_typebase::sink: 'file' must be NULL, a connection or a character string
output_sink("file" = quote(f(x)), "split" = as.raw(c(255)))error_typebase::sink: 'file' must be NULL, a connection or a character string
output_sink(list(local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), quote(f(x))), as.raw(c(0)))error_typebase::sink: 'file' must be NULL, a connection or a character string
output_sink("file" = local({ p <- unserialize(serialize(new("externalptr"), NULL)); attributes(p) <- NULL; p }), "split" = NA)error_typebase::sink: 'file' must be NULL, a connection or a character string
source
output_sink <- function(file = NULL, append = FALSE, split = FALSE) {
  sink(file = file, append = append, type = "output", split = split)
}
R/sink.R:4

message_sink typed any: file fuzz ok

((file: any?, append: lgl1?) -> null)<>
timing: 0.037 s
fuzzing: 8 inside (4 ok, 4 error type) · 7 outside (4 rejected, 3 not forced)

Other calls inside the domain

callverdicterror
message_sink(as.name("x"), as.raw(c(255)))error_typebase::sink: 'file' must be NULL or an already open connection
message_sink(c(Inf, -2.5, -Inf, -2147483647, 0), NA)error_typebase::sink: 'file' must be NULL or an already open connection
message_sink(new.env(), "append" = TRUE)error_typebase::sink: 'file' must be NULL or an already open connection
message_sink(as.name("x"))error_typebase::sink: 'file' must be NULL or an already open connection
source
message_sink <- function(file = NULL, append = FALSE) {
  sink(file = file, append = append, type = "message", split = FALSE)
}
R/sink.R:8

set_output_sink untypeabletyped

unbound variable (line 15)
unbound: file — a name the prelude does not declare
error detail
name: file
gradual mode: typed
any
timing: 0.002 s
source
set_output_sink <- wrap(
  output_sink,
  if (is.null(file)) {
    stop("file cannot be NULL", call. = FALSE)
  },
  list(n = sink.number())
)
R/sink.R:13

set_message_sink untypeabletyped

unbound variable (line 38)
unbound: sink.number — a name the prelude does not declare
error detail
name: sink.number
gradual mode: typed
empty
timing: 0.075 s
source
set_message_sink <- wrap(
  message_sink,
  {
    if (is.null(file)) {
      stop("file cannot be NULL,", call. = FALSE)
    }
    if (sink.number(type = "message") != 2L) {
      stop(
        "Cannot establish message sink when another sink is active.",
        call. = FALSE
      )
    }
    con <- if (is.character(file)) {
      file <- file(file, if (append) "a" else "w")
    }
  },
  {
    list(n = sink.number(type = "message"), con = con)
  }
)
R/sink.R:21

reset_output_sink skipped

error detail
File "Rsem/lang/PAst.ml", line 210, characters 14-20: Assertion failed
timing: 0.000 s
source
reset_output_sink <- function(sink_info) {
  repeat {
    n <- sink.number()
    delta <- n - sink_info$n

    if (delta >= 0L) {
      sink()

      if (delta > 0L) {
        warning("Removing a different sink.", call. = FALSE)
      } else {
        return()
      }
    } else {
      warning("Sink #", sink_info$n, " already removed.", call. = FALSE)
      return()
    }
  }
}
R/sink.R:42

do_reset_message_sink untypeabletyped

unbound variable (line 71)
unbound: sink.number — a name the prelude does not declare
error detail
name: sink.number
gradual mode: typed
((sink_info: { n: any, any }) -> CHR1<> | null)<>
timing: 0.006 s
source
do_reset_message_sink <- function(sink_info) {
  n <- sink.number(type = "message")
  if (n == 2L) {
    warning("No message sink to remove.", call. = FALSE)
  } else if (n == sink_info$n) {
    sink(type = "message")
  } else {
    warning("Not removing a different message sink.", call. = FALSE)
  }
}
R/sink.R:70

reset_message_sink untypeabletyped

unbound variable (line 64)
unbound: on.exit — a name the prelude does not declare
error detail
name: on.exit
gradual mode: typed
((sink_info: { n: any, con: <connection, ...>, any }) | (sink_info: { n: any, con: null, any }) -> CHR1<> | null)<>
timing: 0.100 s
source
reset_message_sink <- function(sink_info) {
  if (!is.null(sink_info$con)) {
    on.exit(close(sink_info$con), add = TRUE)
  }

  do_reset_message_sink(sink_info)
}
R/sink.R:62

with_output_sink untypeabletyped

unbound variable (line 96)
unbound: set_output_sink — one of the package’s own names, itself untyped
error detail
name: set_output_sink
gradual mode: typed
any
timing: 0.000 s
source
with_output_sink <- with_(set_output_sink, reset_output_sink)
R/sink.R:96

local_output_sink untypeabletyped

unbound variable (line 100)
unbound: set_output_sink — one of the package’s own names, itself untyped
error detail
name: set_output_sink
gradual mode: typed
any
timing: 0.000 s
source
local_output_sink <- local_(set_output_sink, reset_output_sink)
R/sink.R:100

with_message_sink untypeabletyped

unbound variable (line 104)
unbound: set_message_sink — one of the package’s own names, itself untyped
error detail
name: set_message_sink
gradual mode: typed
empty
timing: 0.000 s
source
with_message_sink <- with_(set_message_sink, reset_message_sink)
R/sink.R:104

local_message_sink untypeabletyped

unbound variable (line 108)
unbound: set_message_sink — one of the package’s own names, itself untyped
error detail
name: set_message_sink
gradual mode: typed
empty
timing: 0.000 s
source
local_message_sink <- local_(set_message_sink, reset_message_sink)
R/sink.R:108
R/timezone.R

reset_timezone untypeable

unbound variable (line 50)
unbound: baseenv — a name the prelude does not declare
error detail
name: baseenv
timing: 0.008 s
source
reset_timezone <- function(envir = parent.frame()) {
  base_env <- baseenv()
  old <- get0(
    ".sys.timezone",
    base_env,
    mode = "character",
    inherits = FALSE,
    ifnotfound = NA_character_
  )
  is_locked <- bindingIsLocked(".sys.timezone", env = base_env)
  if (is_locked) {
    base_env$unlockBinding(".sys.timezone", env = base_env)
  }
  defer(
    {
      assign(".sys.timezone", old, envir = base_env)
      if (is_locked) {
        lockBinding(".sys.timezone", env = base_env)
      }
    },
    envir = envir
  )
  assign(".sys.timezone", NA_character_, envir = base_env)
}
R/timezone.R:49

with_timezone untypeable

unbound variable (line 23)
unbound: reset_timezone — one of the package’s own names, itself untyped
error detail
name: reset_timezone
timing: 0.006 s
source
with_timezone <- function(tz, code) {
  reset_timezone()
  with_envvar(c(TZ = tz), code)
}
R/timezone.R:22

local_timezone untypeable

unbound variable (line 45)
unbound: reset_timezone — one of the package’s own names, itself untyped
error detail
name: reset_timezone
timing: 0.008 s
source
local_timezone <- function(tz, .local_envir = parent.frame()) {
  reset_timezone(envir = .local_envir)
  local_envvar(c(TZ = tz), .local_envir = .local_envir)
}
R/timezone.R:44
R/torture.R

with_gctorture2 untypeabletyped

unbound variable (line 10)
unbound: gctorture2 — a name the prelude does not declare
error detail
name: gctorture2
gradual mode: typed
any
timing: 0.000 s
source
with_gctorture2 <- with_(gctorture2)
R/torture.R:10

<statement> typed

timing: 0.001 s
source
formals(with_gctorture2)[[3]] <- quote(new)
R/torture.R:11

local_gctorture2 untypeabletyped

unbound variable (line 13)
unbound: gctorture2 — a name the prelude does not declare
error detail
name: gctorture2
gradual mode: typed
any
timing: 0.000 s
source
local_gctorture2 <- local_(gctorture2)
R/torture.R:13

<statement> typed

timing: 0.001 s
source
formals(local_gctorture2)[[2]] <- quote(new)
R/torture.R:14
R/with.R

<statement> typed

timing: 0.003 s
source
"_PACKAGE"
R/with.R:61

.onLoad untypeable

unbound variable (line 72)
unbound: lockBinding — a name the prelude does not declare
error detail
name: lockBinding
timing: 0.021 s
source
.onLoad <- function(...) {
  # Augment rlang with withr features such as knitr support
  on_package_load(
    "rlang",
    local({
      if (is.null(getOption("withr:::inject_defer_override"))) {
        ns <- asNamespace("rlang")

        do.call("unlockBinding", list("defer", ns))
        defer(lockBinding("defer", ns))

        ns$defer <- defer
      }
    })
  )
}
R/with.R:63