Repository navigation
fix: Accept an empty string as a default value in expect_all_args_have_default_values() - #587
Merged
Merged
Conversation
…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
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd7ccM8Y4Gr9rgiWjgH
This was referenced Nov 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
expect_all_args_have_default_values()comparedas.character()of each formal with the empty string. As a result, a default of""counted as missing, and defaults such asNULL,character(), orc("a", "b")mademap_chr()raise an error. The check now usesrlang::is_missing()to find the empty symbol thatformals()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, whilefunction(x),function(x = "", y), andfunction(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