-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zap inline objects from backtraces #1278
Conversation
return(x) | ||
} | ||
|
||
if (is_symbol(x) || is_syntactic_literal(x)) { | ||
x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this slightly easier to understand, but it's not that important
return(x) | |
} | |
if (is_symbol(x) || is_syntactic_literal(x)) { | |
x | |
x | |
} else if (is_symbol(x) || is_syntactic_literal(x)) { | |
x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea here is to keep the terminating and recursive branches separate.
f <- function(...) g() | ||
g <- function() h() | ||
h <- function() trace_back(e) | ||
trace <- inject(f(!!list())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also use do.call()
here, since that's the most common way that users will create inlined objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like along these lines:
e <- environment()
f <- function() do.call("g", list(1:1e6 + 1))
g <- function(...) h()
h <- function() rlang::trace_back(e)
lobstr::obj_size(f())
#> 8,014,888 B
Created on 2021-09-14 by the reprex package (v2.0.0)
(But using something other than obj_size()
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
trace <- f()
trace$calls[[3]]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, I've added a do.call()
and size check in the test.
@@ -40,7 +40,7 @@ | |||
12. \-rlang:::c() | |||
13. +-base::withCallingHandlers(...) | |||
14. +-rlang::with_abort(f()) | |||
15. | \-base::withCallingHandlers(...) | |||
15. | \-base::withCallingHandlers(expr, error = `<fn>`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, not very important, but why does this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The injected handler is now a symbol. This allows as_label()
to keep the whole call instead of eliding.
Closes #1069.
Closes r-lib/testthat#1223.
Inline objects are replaced by their pillar type sum: