From 835fd8644679ebbe1ddfc758c085f75b8475dddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Fri, 9 Oct 2026 17:11:24 +0100 Subject: [PATCH 1/4] fix: issue --- NEWS.md | 3 ++- R/utils-get_code_dependency.R | 2 +- tests/testthat/test-qenv_within.R | 13 +++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index b76159e4..d1e83c12 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,7 +2,8 @@ ### Bug fixes -* Fixed a problem parsing expression referring to the same object (#293) +* Fixed a problem parsing expression referring to the same object (#293). +* Fixed a problem when symbol is being called alone inside an expression (#299). # teal.code 0.7.2 diff --git a/R/utils-get_code_dependency.R b/R/utils-get_code_dependency.R index 27094cdb..9a39b74f 100644 --- a/R/utils-get_code_dependency.R +++ b/R/utils-get_code_dependency.R @@ -398,7 +398,7 @@ extract_dependency <- function(parsed_code) { while (length(queue) > 0) { current <- queue[[1]] queue <- queue[-1] - if (identical(current[[1L]], as.name("{"))) { + if (!is.symbol(current) && identical(current[[1L]], as.name("{"))) { queue <- append(queue, as.list(current)[-1L]) } else { parsed_code <- parse(text = as.expression(current), keep.source = TRUE, encoding = "UTF-8") diff --git a/tests/testthat/test-qenv_within.R b/tests/testthat/test-qenv_within.R index 0df3a5ed..c0daa596 100644 --- a/tests/testthat/test-qenv_within.R +++ b/tests/testthat/test-qenv_within.R @@ -166,3 +166,16 @@ test_that("Chinese characters are handled properly (issue 284)", { expect_equal(lengths(strsplit(get_code(q), split = "\n", fixed = TRUE)), 4L) }) + +test_that("handles name expression inside if clause", { + expect_no_error( + within(qenv(), { + if (TRUE) { + table <- iris + } + if (TRUE) { + table + } + }) + ) +}) From 7e1736a5fd18628765cca3bbb0fc6f553e24ad2e Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 9 Oct 2026 16:16:14 +0000 Subject: [PATCH 2/4] [skip style] [skip vbump] Restyle files --- tests/testthat/test-qenv_within.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-qenv_within.R b/tests/testthat/test-qenv_within.R index c0daa596..6081c078 100644 --- a/tests/testthat/test-qenv_within.R +++ b/tests/testthat/test-qenv_within.R @@ -171,10 +171,10 @@ test_that("handles name expression inside if clause", { expect_no_error( within(qenv(), { if (TRUE) { - table <- iris + table <- iris } if (TRUE) { - table + table } }) ) From abe40cfbec0baab62b16d480a06eb22f6cb842fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Fri, 9 Oct 2026 17:26:29 +0100 Subject: [PATCH 3/4] Fix parsing issue with symbols in expressions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: André Veríssimo <211358+averissimo@users.noreply.github.com> --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index d1e83c12..93b8d15c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,7 +3,7 @@ ### Bug fixes * Fixed a problem parsing expression referring to the same object (#293). -* Fixed a problem when symbol is being called alone inside an expression (#299). +* Fixed a problem when a symbol appears alone inside an expression (#299). # teal.code 0.7.2 From 7115c7edc6e238b126288fe8a2288ea80a5529b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Wed, 14 Oct 2026 17:39:18 +0100 Subject: [PATCH 4/4] Update R/utils-get_code_dependency.R MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: André Veríssimo <211358+averissimo@users.noreply.github.com> --- R/utils-get_code_dependency.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/utils-get_code_dependency.R b/R/utils-get_code_dependency.R index 9a39b74f..f7f73882 100644 --- a/R/utils-get_code_dependency.R +++ b/R/utils-get_code_dependency.R @@ -398,7 +398,7 @@ extract_dependency <- function(parsed_code) { while (length(queue) > 0) { current <- queue[[1]] queue <- queue[-1] - if (!is.symbol(current) && identical(current[[1L]], as.name("{"))) { + if (typeof(current) == "language" && inherits(current, "{")) { queue <- append(queue, as.list(current)[-1L]) } else { parsed_code <- parse(text = as.expression(current), keep.source = TRUE, encoding = "UTF-8")