Bug 16047 - Bug in abs() with named complex argument
Summary: Bug in abs() with named complex argument
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Low-level (show other bugs)
Version: R 3.1.1
Hardware: x86_64/x64/amd64 (64-bit) Linux
: P5 minor
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2014-10-27 14:57 UTC by Ege Rubak
Modified: 2014-11-03 15:04 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ege Rubak 2014-10-27 14:57:49 UTC
Naming a complex argument to abs() generates the following error:

> abs(x=1i)
Error in abs(x = 0+1i) : supplied argument name 'x' does not match 'z'

I'm running the latest svn version with the following sessionInfo:

> sessionInfo()
R Under development (unstable) (2014-10-27 r66885)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_DK.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
Comment 1 Peter Dalgaard 2014-10-27 16:43:13 UTC
Don't do that then...

However, this is a bit ridiculous and should get fixed eventually:

> abs(x=1i)
Error in abs(x = 0+1i) : supplied argument name 'x' does not match 'z'
> abs(z=1i)
Error in abs(z = 0+1i) : supplied argument name 'z' does not match 'x'

As far as I can tell, the problem is that do_abs checks for argument name 'x', then calls do_cmathfuns which checks for argument name 'z'.
Comment 2 Ege Rubak 2014-10-27 19:12:49 UTC
I agree it seems unnecessary to use a named argument in abs(), but it came about when I was defining a 'Math group' method for a new class, and I just figured you wanted to know about this small incovenience/inconsistency. Naturally, I can work around this.
Comment 3 Duncan Murdoch 2014-11-03 15:04:53 UTC
I'll fix this in R-devel and R-patched.  The fix will be to remove the name from the arg after checking in do_abs, before sending to do_cmathfuns.