diff options
author | Jeremy Evans <[email protected]> | 2019-08-07 09:01:33 -0700 |
---|---|---|
committer | Jeremy Evans <[email protected]> | 2019-09-21 16:10:37 -0700 |
commit | 2e551356a7a6e74ba07283e000ff16f5d1ea6506 (patch) | |
tree | 99c123bb12c43346d9b1748cd73c42b883c6bb0a /ext/pathname/pathname.c | |
parent | 7470f965650bf17875632f0c5f9e5a4d9de9fc3f (diff) |
Make Kernel#{Pathname,BigDecimal,Complex} return argument if given correct type
This is how Kernel#{Array,String,Float,Integer,Hash,Rational} work.
BigDecimal and Complex instances are always frozen, so this should
not cause backwards compatibility issues for those. Pathname
instances are not frozen, so potentially this could cause backwards
compatibility issues by not returning a new object.
Based on a patch from Joshua Ballanco, some minor changes by me.
Fixes [Bug #7522]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2473
Diffstat (limited to 'ext/pathname/pathname.c')
-rw-r--r-- | ext/pathname/pathname.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c index 70f82583a1..1cf0f90b9f 100644 --- a/ext/pathname/pathname.c +++ b/ext/pathname/pathname.c @@ -1323,6 +1323,8 @@ path_unlink(VALUE self) static VALUE path_f_pathname(VALUE self, VALUE str) { + if (CLASS_OF(str) == rb_cPathname) + return str; return rb_class_new_instance(1, &str, rb_cPathname); } |