Skip to content

fix: Accept an empty string as a default value in expect_all_args_have_default_values() - #587

Merged
krlmlr merged 3 commits into
mainfrom
claude/fix-293-empty-default
Nov 28, 2026
Merged

krlmlr merged 3 commits into
mainfrom
claude/fix-293-empty-default

Conversation

@krlmlr

@krlmlr krlmlr commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

expect_all_args_have_default_values() compared as.character() of each formal with the empty string. As a result, a default of "" counted as missing, and defaults such as NULL, character(), or c("a", "b") made map_chr() raise an error. The check now uses rlang::is_missing() to find the empty symbol that formals() stores for an argument without a default. A new test file, tests/testthat/test-expectations.R, covers both sides: function(x = "", y = NULL, z = character(), w = c("a", "b"), ...) passes, while function(x), function(x = "", y), and function(x, ...) fail.

Why backends can't break: the change only removes false failures. The old check passed only when every formal had a non-empty character form. The empty symbol is the only formal whose form is "" and that the new check rejects, so every constructor that passed before still passes. Constructors that used to fail or error because of "", NULL, or call defaults now pass. The full test suite passes locally: [ FAIL 0 | WARN 0 | SKIP 64 | PASS 9637 ].

Closes #293.

A clean review found nothing above Low; its two points (the tests did not check the failure message, and did not cover NA, symbol and call defaults or an argument after ...) are addressed in the second commit.

Requested in #585.

https://claude.ai/code/session_01Hr1rd7ccM8Y4Gr9rgiWjgH


Generated by Claude Code

…ve_default_values()`

The check compared the character representation of each default with the empty string,
so a default of `""` counted as missing, and defaults such as `NULL` or `c("a", "b")` raised an error.
It now looks for the empty symbol that `formals()` uses for an argument without a default.

Closes #293

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd7ccM8Y4Gr9rgiWjgH
Follows up on the review of the empty-string fix:
`NA`, a symbol and a call count as defaults,
and an argument after `...` without a default is reported.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hr1rd7ccM8Y4Gr9rgiWjgH
@krlmlr
krlmlr merged commit a5ba401 into main Nov 28, 2026
17 checks passed
@krlmlr
krlmlr deleted the claude/fix-293-empty-default branch November 28, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Driver constructor with default argument "" triggers false positive

2 participants