Skip to content
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

expect_error() (& friends) error could be friendlier for mis-named argument #2054

Open
MichaelChirico opened this issue Jan 15, 2025 · 0 comments · May be fixed by #2055
Open

expect_error() (& friends) error could be friendlier for mis-named argument #2054

MichaelChirico opened this issue Jan 15, 2025 · 0 comments · May be fixed by #2055

Comments

@MichaelChirico
Copy link
Contributor

MichaelChirico commented Jan 15, 2025

Updating to 3.2.3 broke some tests. The biggest thing was usage like this:

Sys.setenv(TESTTHAT_EDITION=3)
expect_error(stop("hello"), msg="bye")

### 3.2.1.1
# Warning message:
# In expect_error(stop("hello"), msg = "bye") :
#   Arguments in `...` must be used.
# ✖ Problematic argument:
# • msg = "hello"
# ℹ Did you misspell an argument name?

### 3.2.3
# Error in `expect_error()`:
# ! Can't specify `...` without `pattern`.
# Run `rlang::last_trace()` to see where the error occurred.

Previously, the tests would pass somewhat spuriously, as in effect the msg argument is totally ignored, i.e. it's equivalent to just running expect_error(stop("hello")) which only checks the condition is thrown, not its contents.

The change in 3.2.3 is definitely for the better (this flushed out some tests checking for the wrong message), but the old warning was clearer & more actionable. Even putting aside #2053, it's hard to tie together "... is specified" means "some named argument didn't match formals --> wound up passing to ...". Simply restoring the informative "problematic argument" tag would do a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant