diff --git a/DESCRIPTION b/DESCRIPTION index 6d3df99..3d13032 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: typetracer Title: Trace Function Parameter Types -Version: 0.1.1.013 +Version: 0.1.1.014 Authors@R: c( person("Mark", "Padgham", , "mark.padgham@email.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-2172-5265")), diff --git a/R/tracer-define.R b/R/tracer-define.R index 07ef466..6308532 100644 --- a/R/tracer-define.R +++ b/R/tracer-define.R @@ -129,8 +129,11 @@ typetracer_header <- function () { if (length (index) > 0L) { call_envs$namespace [index] <- trace_dat$scope [index] } - call_envs <- - call_envs [which (!call_envs$name == typetracer_env$fn_name), ] + call_envs <- call_envs [which (call_envs$namespace != "typetracer"), ] + if (nrow (call_envs) > 0L) { + # assume first branch of trace_back is desired env + call_envs <- call_envs [1, ] + } list ( par = p, diff --git a/codemeta.json b/codemeta.json index 07c0208..25e5406 100644 --- a/codemeta.json +++ b/codemeta.json @@ -11,7 +11,7 @@ "codeRepository": "https://github.com/mpadge/typetracer", "issueTracker": "https://github.com/mpadge/typetracer/issues", "license": "https://spdx.org/licenses/MIT", - "version": "0.1.1.013", + "version": "0.1.1.014", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", diff --git a/tests/testthat/_snaps/trace-fns.md b/tests/testthat/_snaps/trace-fns.md index b0d0674..c72f3f0 100644 --- a/tests/testthat/_snaps/trace-fns.md +++ b/tests/testthat/_snaps/trace-fns.md @@ -83,8 +83,11 @@ if (length(index) > 0L) { call_envs$namespace[index] <- trace_dat$scope[index] } - call_envs <- call_envs[which(!call_envs$name == typetracer_env$fn_name), + call_envs <- call_envs[which(call_envs$namespace != "typetracer"), ] + if (nrow(call_envs) > 0L) { + call_envs <- call_envs[1, ] + } list(par = p, class = class(res), typeof = typeof(res), storage_mode = storage.mode(res), mode = mode(res), length = length(res), par_uneval = s, par_eval = res,