posit-dev / positron

Positron, a next-generation data science IDE
Other
2.5k stars 76 forks source link

uninformative error for invalid R code inside `test_that()` chunk #3315

Open EmilHvitfeldt opened 4 months ago

EmilHvitfeldt commented 4 months ago

Positron Version:

Positron Version: 2024.05.0 (Universal) build 1313 Code - OSS Version: 1.89.0 Commit: b8e508681e4ef1cb4ac98c52f5ca9111ca5728de Date: 2024-05-29T03:53:21.563Z Electron: 28.2.8 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Darwin arm64 23.4.0

Steps to reproduce the issue:

  1. Write a longish test_that() chunk

(the second to the last all_numeric_predictors() is missing its closing parameter

test_that("ignore_step() works", {
  rec <- recipe(mpg ~ ., data = mtcars)

  rec1234 <- recipe(mpg ~ ., data = mtcars) %>%
    step_dummy(all_nominal_predictors(), id = "dummy") %>%
    step_impute_mean(all_numeric_predictors(), id = "impute_mean") %>%
    step_normalize(all_numeric_predictors()) %>%
    step_pca(all_numeric_predictors(), id = "pca")

  rec234 <- recipe(mpg ~ ., data = mtcars) %>%
    step_impute_mean(all_numeric_predictors(), id = "impute_mean") %>%
    step_normalize(all_numeric_predictors()) %>%
    step_pca(all_numeric_predictors(), id = "pca")

  rec34 <- recipe(mpg ~ ., data = mtcars) %>%
    step_dummy(all_nominal_predictors(), id = "dummy") %>%
    step_impute_mean(all_numeric_predictors(), id = "impute_mean") %>%
    step_normalize(all_numeric_predictors()) %>%
    step_pca(all_numeric_predictors(), id = "pca")

  rec123 <- recipe(mpg ~ ., data = mtcars) %>%
    step_dummy(all_nominal_predictors(), id = "dummy") %>%
    step_impute_mean(all_numeric_predictors(, id = "impute_mean") %>%
    step_normalize(all_numeric_predictors())

  expect_identical(
    ignore_step(rec1234, number = 1),
    rec234
  )

  ignore_step(rec, number = 1)
})

https://github.com/posit-dev/positron/assets/14034784/b7bfb155-1ced-4aa3-80fb-4fb9a954e84f

What did you expect to happen?

For a more informative message to appear.

Screenshot 2024-05-29 at 3 48 25 PM

RStudio gives a "Unmatched opening bracket"

Were there any error messages in the output or Developer Tools console?

Nope

EmilHvitfeldt commented 4 months ago

it feels like it is related to test_that() as if you remove that but keeps the {} you get different danger squiggly lines

Screenshot 2024-05-29 at 3 55 07 PM Screenshot 2024-05-29 at 3 55 14 PM

juliasilge commented 4 months ago

I believe this is related to #2943