From 618efbb080a1248dd05a44207841bebf134945e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Tue, 6 May 2025 15:03:55 +0100 Subject: [PATCH 01/10] fix: creates special case for '=' --- R/qenv-eval_code.R | 8 +++++++- tests/testthat/test-qenv_within.R | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/R/qenv-eval_code.R b/R/qenv-eval_code.R index b8593a33f..49e3f0189 100644 --- a/R/qenv-eval_code.R +++ b/R/qenv-eval_code.R @@ -98,7 +98,13 @@ setMethod("eval_code", signature = c("qenv", "expression"), function(object, cod if (length(srcref)) { eval_code(object, code = paste(attr(code, "wholeSrcref"), collapse = "\n")) } else { - Reduce(eval_code, init = object, x = code) + Reduce(function(u, v) { + if (inherits(v, "=")) { + eval_code(object, paste(vapply(lang2calls(v), deparse1, collapse = "\n", character(1L)), collapse = "\n")) + } else { + eval_code(object = u, code = v) + } + }, init = object, x = code) } }) diff --git a/tests/testthat/test-qenv_within.R b/tests/testthat/test-qenv_within.R index b4e41d0c0..db121e061 100644 --- a/tests/testthat/test-qenv_within.R +++ b/tests/testthat/test-qenv_within.R @@ -131,3 +131,21 @@ testthat::test_that("within run on qenv.error returns the qenv.error as is", { testthat::expect_identical(qe, qee) }) + +testthat::describe("within run with `=`", { + testthat::it("single expression", { + q <- qenv() + q <- within(q, { + i = 1 + }) + }) + + testthat::it("multiple expressions", { + q <- qenv() + q <- within(q, { + j <- 2 + i = 1 + }) + testthat::expect_equal(q$i, 1) + }) +}) From c889a3648eb80057171d23c3b67d028cca7f3f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Tue, 6 May 2025 15:42:20 +0100 Subject: [PATCH 02/10] chore: minor code cleanup to avoid new function definition --- R/qenv-eval_code.R | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/R/qenv-eval_code.R b/R/qenv-eval_code.R index 49e3f0189..0eafe0ce9 100644 --- a/R/qenv-eval_code.R +++ b/R/qenv-eval_code.R @@ -99,11 +99,13 @@ setMethod("eval_code", signature = c("qenv", "expression"), function(object, cod eval_code(object, code = paste(attr(code, "wholeSrcref"), collapse = "\n")) } else { Reduce(function(u, v) { - if (inherits(v, "=")) { - eval_code(object, paste(vapply(lang2calls(v), deparse1, collapse = "\n", character(1L)), collapse = "\n")) + f <- if (inherits(v, "=")) { + # Force method to be called + getMethod("eval_code", signature = c("qenv", "language"))@.Data } else { - eval_code(object = u, code = v) + eval_code } + f(u, v) }, init = object, x = code) } }) From da6f45e5dddc890b7578063cde6d5706b47813de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Tue, 6 May 2025 16:22:01 +0100 Subject: [PATCH 03/10] fix: manually add language class --- R/qenv-eval_code.R | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/R/qenv-eval_code.R b/R/qenv-eval_code.R index 0eafe0ce9..4dd147d4b 100644 --- a/R/qenv-eval_code.R +++ b/R/qenv-eval_code.R @@ -99,13 +99,10 @@ setMethod("eval_code", signature = c("qenv", "expression"), function(object, cod eval_code(object, code = paste(attr(code, "wholeSrcref"), collapse = "\n")) } else { Reduce(function(u, v) { - f <- if (inherits(v, "=")) { - # Force method to be called - getMethod("eval_code", signature = c("qenv", "language"))@.Data - } else { - eval_code + if (inherits(v, "=") && identical(typeof(v), "language")) { + class(v) <- unique(c("language", class(v))) } - f(u, v) + eval_code(u, v) }, init = object, x = code) } }) From dc550ddda407068ecc885fc89ff8d75462235165 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 15:26:43 +0000 Subject: [PATCH 04/10] [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 db121e061..2e882da5f 100644 --- a/tests/testthat/test-qenv_within.R +++ b/tests/testthat/test-qenv_within.R @@ -136,7 +136,7 @@ testthat::describe("within run with `=`", { testthat::it("single expression", { q <- qenv() q <- within(q, { - i = 1 + i <- 1 }) }) @@ -144,7 +144,7 @@ testthat::describe("within run with `=`", { q <- qenv() q <- within(q, { j <- 2 - i = 1 + i <- 1 }) testthat::expect_equal(q$i, 1) }) From b46feff887349710141cde4d2d13b87f2a6e6536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Tue, 6 May 2025 17:36:54 +0100 Subject: [PATCH 05/10] empty: trigger CI From 674d872a7fc99734a7e3c1cfd00f183a114581d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Tue, 20 May 2025 08:16:04 +0100 Subject: [PATCH 06/10] fix: test is using <- instead of = --- tests/testthat/test-qenv_within.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-qenv_within.R b/tests/testthat/test-qenv_within.R index 2e882da5f..826659b0c 100644 --- a/tests/testthat/test-qenv_within.R +++ b/tests/testthat/test-qenv_within.R @@ -136,15 +136,15 @@ testthat::describe("within run with `=`", { testthat::it("single expression", { q <- qenv() q <- within(q, { - i <- 1 + i = 1 }) }) - testthat::it("multiple expressions", { + testthat::it("multiple '=' expressions", { q <- qenv() q <- within(q, { - j <- 2 - i <- 1 + j = 2 + i = 1 }) testthat::expect_equal(q$i, 1) }) From 44f924b55d528ba56eaaa664fedbdbbd9cf45f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Tue, 20 May 2025 08:18:06 +0100 Subject: [PATCH 07/10] chore: add comment to give full context on exception from @m7pr --- R/qenv-eval_code.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/qenv-eval_code.R b/R/qenv-eval_code.R index 4dd147d4b..14af1ae78 100644 --- a/R/qenv-eval_code.R +++ b/R/qenv-eval_code.R @@ -100,6 +100,8 @@ setMethod("eval_code", signature = c("qenv", "expression"), function(object, cod } else { Reduce(function(u, v) { if (inherits(v, "=") && identical(typeof(v), "language")) { + # typeof(`=`) is language, but it doesn't dispatch on it, so we need to + # explicitly pass it as first class of the object class(v) <- unique(c("language", class(v))) } eval_code(u, v) From 007f2269577cc71ce188f7c3bebacb67bb1a0275 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 20 May 2025 07:20:07 +0000 Subject: [PATCH 08/10] [skip style] [skip vbump] Restyle files --- tests/testthat/test-qenv_within.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-qenv_within.R b/tests/testthat/test-qenv_within.R index 826659b0c..a29a0f1b3 100644 --- a/tests/testthat/test-qenv_within.R +++ b/tests/testthat/test-qenv_within.R @@ -136,15 +136,15 @@ testthat::describe("within run with `=`", { testthat::it("single expression", { q <- qenv() q <- within(q, { - i = 1 + i <- 1 }) }) testthat::it("multiple '=' expressions", { q <- qenv() q <- within(q, { - j = 2 - i = 1 + j <- 2 + i <- 1 }) testthat::expect_equal(q$i, 1) }) From 5323b1d630e128cccd345372d7dfd41889e641ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Tue, 20 May 2025 08:27:44 +0100 Subject: [PATCH 09/10] chore: add styler off comment to prevent test modification --- tests/testthat/test-qenv_within.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-qenv_within.R b/tests/testthat/test-qenv_within.R index a29a0f1b3..1f15c2241 100644 --- a/tests/testthat/test-qenv_within.R +++ b/tests/testthat/test-qenv_within.R @@ -136,15 +136,15 @@ testthat::describe("within run with `=`", { testthat::it("single expression", { q <- qenv() q <- within(q, { - i <- 1 + i = 1 # styler: off }) }) testthat::it("multiple '=' expressions", { q <- qenv() q <- within(q, { - j <- 2 - i <- 1 + j = 2 # styler: off + i = 1 # styler: off }) testthat::expect_equal(q$i, 1) }) From c11303dd5a4bf69d2b828f84589b952a31fdd717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Tue, 20 May 2025 08:35:49 +0100 Subject: [PATCH 10/10] chore: add lintr exceptions --- tests/testthat/test-qenv_within.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-qenv_within.R b/tests/testthat/test-qenv_within.R index 1f15c2241..9853b4608 100644 --- a/tests/testthat/test-qenv_within.R +++ b/tests/testthat/test-qenv_within.R @@ -136,15 +136,15 @@ testthat::describe("within run with `=`", { testthat::it("single expression", { q <- qenv() q <- within(q, { - i = 1 # styler: off + i = 1 # nolintr: assigment. styler: off. }) }) testthat::it("multiple '=' expressions", { q <- qenv() q <- within(q, { - j = 2 # styler: off - i = 1 # styler: off + j = 2 # nolintr: assigment. styler: off. + i = 1 # nolintr: assigment. styler: off. }) testthat::expect_equal(q$i, 1) })