Bug 17252 - [Wishlist] Warn about non-matched named arguments to 'paste', 'paste0'?
Summary: [Wishlist] Warn about non-matched named arguments to 'paste', 'paste0'?
Status: UNCONFIRMED
Alias: None
Product: R
Classification: Unclassified
Component: Wishlist (show other bugs)
Version: R-devel (trunk)
Hardware: Other Other
: P5 enhancement
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2017-04-04 18:18 UTC by Kevin Ushey
Modified: 2017-04-19 17:03 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Ushey 2017-04-04 18:18:15 UTC
Given the code:

    paste(c("a", "b"), collapase = "\n")

One might surmise that the user intended to type 'collapse', but instead wrote 'collapase' by accident. R executes this code without warning:

    > paste(c("a", "b"), collapase = "\n")
    [1] "a \n" "b \n"

although this is not the desired result. It might be worth:

    1) Having paste warn when `...` receives named arguments, or
    2) Have R CMD check warn if it sees calls to 'paste' of this form (ie, with explicit named formals not called 'collapse' or 'sep'.

I think (1) could be a bit controversial since in theory a user might write something like `do.call(paste, <...>)`, where the call to `paste` does receive named arguments, but still acts as the user expects. (2) may be a nice addition and presumedly would be a relatively small extension to the 'codetools' package.
Comment 1 Duncan Murdoch 2017-04-19 17:03:38 UTC
I think that you're right that a warning from paste() would generate too much noise, so the codetools check is probably better.  However, codetools is a recommended package, not precisely part of R, and I suspect its maintainer is quite busy.  

What you might do is work out what the code for the test should look like, and submit a patch to him that either includes just that patch, or a way for users to supply their own checks to codetools.  If you did the latter, then it would be feasible to add this check (and perhaps others) into the R CMD check code.