Skip to content

Can't change default arguments #728

Closed

Description

@hadley

Found while verifying scenarios for the evolution vignette (#143).

When pkgA changes the default value of a non-dispatch argument of a generic, every downstream method that spells out the old default triggers the default-mismatch warning from check_method():

Warning: In gen(<pkgB::BClass>), default value of `drop` is not the same as the generic
- Generic: TRUE
- Method:  FALSE

This warning fires when pkgB is installed (an R CMD check WARNING via "significant warnings") and again on every load (a check NOTE). Unlike adding an argument — where a method can include the new argument ahead of time and is silently accepted by both old and new generic — there is no version of the method that is warning-free under both versions of pkgA: whichever default it picks disagrees with one of them. So pkgA can't change a default without making every downstream package's checks noisy for the duration of the transition, no matter how cooperative the downstream authors are.

Maybe we only fire this when running R CMD check for pkgB or under pkgload? (i.e. _R_CHECK_PACKAGE_NAME_)

Related: because dispatch passes the method's formals, the method's default is what callers actually get, so these mismatches are genuine behavioral drift — whatever mechanism we pick should preserve that signal.

Activity

  1. changed the title [-]No warning-free way for a downstream method to survive a change to a generic argument's default[/-] [+]Can't change default arguments[/+] on Jul 27, 2026
  2. added a commit that references this issue on Jul 31, 2026
  3. added a commit that references this issue on Oct 2, 2026
    642fe0d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions