165 trim trace for qenv.error@main - #183
Conversation
Code Coverage SummaryDiff against mainResults for commit: 71116d7 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
chlebowa
left a comment
There was a problem hiding this comment.
> devtools::load_all()
ℹ Loading teal.code
> qe <- qenv() |> within(i <- iris) |> within(stop("oh no"))
> qe
<qenv.error: oh no
when evaluating qenv code:
stop("oh no")>
> get_code(qe)
Error: oh no
when evaluating qenv code:
stop("oh no")
trace:
i <- iris
stop("oh no")
This is what I intended 👍
As long as you're here, would you mind modifying this line in get_code like it was changed in teal_data::get_code?
# from
parse(text = paste(c("{", object@code, "}"), collapse = "\n"), keep.source = TRUE)
# to
parse(text = object@code, keep.source = TRUE)
I disabled auto-merge to give you chance.
|
Hey @chlebowa why would we want to change this? The line parse(text = paste(c("{", object@code, "}"), collapse = "\n"), keep.source = TRUE)was introduced in here #176 so that resulted expression (for |
|
before: after: |
|
Hey @chlebowa your before and after are the same. The line you mentioned is for # parse(text = object@code, keep.source = TRUE) case
qe <- qenv() |> within(i <- iris) |> within(m <- mtcars)
get_code(qe, deparse = FALSE)
# > expression(i <- iris, m <- mtcars)
length(get_code(qe, deparse = FALSE))
# > [1] 2# parse(text = paste(c("{", object@code, "}"), collapse = "\n"), keep.source = TRUE) case
qe <- qenv() |> within(i <- iris) |> within(m <- mtcars)
get_code(qe, deparse = FALSE)
# > expression({
# > i <- iris
# > m <- mtcars
# > })
length(get_code(qe, deparse = FALSE))
# > [1] 1 |
|
If we are trying to be consistent with what's in https://github.com/insightsengineering/teal.data/blob/main/R/teal_data-get_code.R#L60 then I would actually modify what's in |
|
library(teal.data)
tdata1 <- teal_data()
tdata1 <- within(tdata1, {
a <- 1
b <- a^5
c <- list(x = 2)
})
length(get_code(tdata1, deparse = FALSE))
# > [1] 3
length(get_code(tdata1, deparse = TRUE))
# > [1] 1 |
|
I stand corrected, I ran my tests wrong. Merge away. |
|
No worries, I made an issue in |

Close #165