zverok
c1bd1bf272
Document Module#const_source_location
2019-12-23 08:30:21 +09:00
Jeremy Evans
ffd0820ab3
Deprecate taint/trust and related methods, and make the methods no-ops
...
This removes the related tests, and puts the related specs behind
version guards. This affects all code in lib, including some
libraries that may want to support older versions of Ruby.
2019-11-18 01:00:25 +02:00
Nobuyoshi Nakada
f72dc407f2
Prohibit calling undefined allocator [Bug #16297 ]
2019-11-06 11:17:09 +09:00
Jean Boussier
eff15a269f
[EXPERIMENTAL] Make NilClass#to_s, TrueClass#to_s and FalseClass#to_s return a frozen String
...
* Always the same frozen String for each of these values.
* Avoids extra allocations whenever calling these 3 methods.
* See [Feature #16150 ]
2019-09-27 13:52:33 +09:00
Jeremy Evans
27b6746872
Make passing empty keywords to dig pass empty keywords to next dig method
...
If defined in Ruby, dig would be defined as def dig(arg, *rest) end,
it would not use keywords. If the last dig argument was an empty
hash, it could be treated as keyword arguments by the next dig
method. Allow dig to pass along the empty keyword flag if called
with an empty keyword, to suppress the previous behavior and force
treating the hash as a positional argument and not keywords.
Also handle the case where dig calls method_missing, passing the
empty keyword flag to that as well.
This requires adding rb_check_funcall_with_hook_kw functions, so
that dig can specify how arguments are treated. It also adds
kw_splat arguments to a couple static functions.
2019-09-20 07:45:11 -07:00
Jeremy Evans
b78a345bd6
Only set RB_PASS_CALLED_KEYWORDS in C functions called directly from Ruby
...
It is not safe to set this in C functions that can be called from
other C functions, as in the non argument-delegation case, you
can end up calling a Ruby method with a flag indicating keywords
are set without passing keywords.
Introduce some new *_kw functions that take a kw_splat flag and
use these functions to set RB_PASS_CALLED_KEYWORDS in places where
we know we are delegating methods (e.g. Class#new, Method#call)
2019-09-14 01:49:33 -07:00
卜部昌平
bfe5d22f89
drop-in type check for rb_define_private_method
...
We can check the function pointer passed to rb_define_private_method
like how we do so in rb_define_method. Doing so revealed some
problematic usages of rb_obj_dummy. They had to be split according
to their arity.
2019-08-29 18:34:09 +09:00
卜部昌平
0766f67168
move docs around [ci skip]
...
To properly generate documents.
2019-08-29 18:34:09 +09:00
卜部昌平
7bcfd9189a
drop-in type check for rb_define_global_function
...
We can check the function pointer passed to rb_define_global_function
like we do so in rb_define_method. It turns out that almost anybody
is misunderstanding the API.
2019-08-29 18:34:09 +09:00
Jeremy Evans
04735c48ab
Minor documentation fixes [ci skip]
...
From zverok (Victor Shepelev)
Fixes [Misc #16126 ]
2019-08-24 14:05:19 -07:00
Jeremy Evans
e1c991f8d7
Move Object#hash rdoc to hash.c [ci skip]
...
This gets RDoc to pick up the documentation correctly.
Problem pointed out by zverok (Victor Shepelev).
2019-08-24 09:09:53 -07:00
songhuangcn
d2070f2e45
Fix doc in Object#respond_to_missing? ( #2239 )
2019-08-16 00:20:52 +09:00
Yusuke Endoh
086ffe72c7
Revert "Revert "Add a specialized instruction for `.nil?` calls""
...
This reverts commit a0980f2446
.
Retry for macOS Mojave.
2019-08-02 23:25:38 +09:00
Yusuke Endoh
a0980f2446
Revert "Add a specialized instruction for `.nil?` calls"
...
This reverts commit 9faef3113f
.
It seemed to cause a failure on macOS Mojave, though I'm unsure how.
https://rubyci.org/logs/rubyci.s3.amazonaws.com/osx1014/ruby-master/log/20190802T034503Z.fail.html.gz
This tentative revert is to check if the issue is actually caused by the
change or not.
2019-08-02 15:03:34 +09:00
Aaron Patterson
31ec475ad8
Update object.c
...
Co-Authored-By: Takashi Kokubun <takashikkbn@gmail.com>
2019-07-31 16:36:25 -07:00
Aaron Patterson
9faef3113f
Add a specialized instruction for `.nil?` calls
...
This commit adds a specialized instruction for called to `.nil?`. It is
about 27% faster than master in the case where the object is nil or not
nil. In the case where an object implements `nil?`, I think it may be
slightly slower. Here is a benchmark:
```ruby
require "benchmark/ips"
class Niller
def nil?; true; end
end
not_nil = Object.new
xnil = nil
niller = Niller.new
Benchmark.ips do |x|
x.report("nil?") { xnil.nil? }
x.report("not nil") { not_nil.nil? }
x.report("niller") { niller.nil? }
end
```
On Ruby master:
```
[aaron@TC ~/g/ruby (master)]$ ./ruby compil.rb
Warming up --------------------------------------
nil? 429.195k i/100ms
not nil 437.889k i/100ms
niller 437.935k i/100ms
Calculating -------------------------------------
nil? 20.166M (± 8.1%) i/s - 100.002M in 5.002794s
not nil 20.046M (± 7.6%) i/s - 99.839M in 5.020086s
niller 22.467M (± 6.1%) i/s - 112.111M in 5.013817s
[aaron@TC ~/g/ruby (master)]$ ./ruby compil.rb
Warming up --------------------------------------
nil? 449.660k i/100ms
not nil 433.836k i/100ms
niller 443.073k i/100ms
Calculating -------------------------------------
nil? 19.997M (± 8.8%) i/s - 99.375M in 5.020458s
not nil 20.529M (± 7.0%) i/s - 102.385M in 5.020689s
niller 21.796M (± 8.0%) i/s - 108.110M in 5.002300s
[aaron@TC ~/g/ruby (master)]$ ./ruby compil.rb
Warming up --------------------------------------
nil? 402.119k i/100ms
not nil 438.968k i/100ms
niller 398.226k i/100ms
Calculating -------------------------------------
nil? 20.050M (±12.2%) i/s - 98.519M in 5.008817s
not nil 20.614M (± 8.0%) i/s - 102.280M in 5.004531s
niller 22.223M (± 8.8%) i/s - 110.309M in 5.013106s
```
On this branch:
```
[aaron@TC ~/g/ruby (specialized-nilp)]$ ./ruby compil.rb
Warming up --------------------------------------
nil? 468.371k i/100ms
not nil 456.517k i/100ms
niller 454.981k i/100ms
Calculating -------------------------------------
nil? 27.849M (± 7.8%) i/s - 138.169M in 5.001730s
not nil 26.417M (± 8.7%) i/s - 131.020M in 5.011674s
niller 21.561M (± 7.5%) i/s - 107.376M in 5.018113s
[aaron@TC ~/g/ruby (specialized-nilp)]$ ./ruby compil.rb
Warming up --------------------------------------
nil? 477.259k i/100ms
not nil 428.712k i/100ms
niller 446.109k i/100ms
Calculating -------------------------------------
nil? 28.071M (± 7.3%) i/s - 139.837M in 5.016590s
not nil 25.789M (±12.9%) i/s - 126.470M in 5.011144s
niller 20.002M (±12.2%) i/s - 98.144M in 5.001737s
[aaron@TC ~/g/ruby (specialized-nilp)]$ ./ruby compil.rb
Warming up --------------------------------------
nil? 467.676k i/100ms
not nil 445.791k i/100ms
niller 415.024k i/100ms
Calculating -------------------------------------
nil? 26.907M (± 8.0%) i/s - 133.755M in 5.013915s
not nil 25.319M (± 7.9%) i/s - 125.713M in 5.007758s
niller 19.569M (±11.8%) i/s - 96.286M in 5.008533s
```
Co-Authored-By: Ashe Connor <kivikakk@github.com>
2019-07-31 16:21:25 -07:00
Jeremy Evans
8bccbf3cfe
Add more documentation on #eql?/#hash relationship [ci skip]
...
Fixes [Bug #14263 ]
2019-07-26 17:05:46 -07:00
Jeremy Evans
6279cf8b2b
Restore documentation for Object#hash [ci skip]
...
Object#hash documentation was removed (probably by accident) in
7b19e6f3fd
.
2019-07-26 16:57:42 -07:00
Nobuyoshi Nakada
3e7d002118
Check exception flag as a bool [Bug #15987 ]
2019-07-11 20:04:29 +09:00
Nobuyoshi Nakada
4cda2e5013
Moved error messages
2019-07-09 10:58:12 +09:00
git
c5c3486340
* expand tabs.
2019-06-23 01:47:40 +09:00
Nobuyoshi Nakada
9384383019
Module#constant_source_location [Feature #10771 ]
2019-06-23 01:46:38 +09:00
Luke Gruber
02b1a85385
remove 2 redundant calls to rb_str_dup
...
Because `rb_class_path` calls `rb_str_dup` already.
Closes: https://github.com/ruby/ruby/pull/2232
2019-06-13 18:05:04 +09:00
Jean Boussier
7d805e67f3
Avoid triggering autoload in Module#const_defined?(String)
...
[Bug #15780 ]
2019-05-07 21:20:01 +09:00
nobu
d10451f3fd
object.c: fix searching nested const paths
...
* object.c (rb_mod_const_get, rb_mod_const_defined): nested const
paths should not search from toplevel constants.
[ruby-core:92202] [Bug #15758 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-08 13:47:37 +00:00
nobu
56557ec28a
[DOC] fix markups [ci skip]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-22 11:04:59 +00:00
nobu
7fa16fd962
Fix `Module#const_defined?` on inherited constants
...
[Fix GH-2061]
From: manga_osyo <manga.osyo@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-28 13:32:32 +00:00
nobu
4e28fdf417
No FloatDomainError at non-finitive number if exception: false
...
[ruby-core:91021] [Bug #15525 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-12 09:36:52 +00:00
kazu
bace0d4cdc
[DOC] Add `or nil` to call-seq [ci skip]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-03 05:51:18 +00:00
mame
e030e9f0b8
object.c (rb_obj_match): use rb_warn for deprecation warning
...
Now the warning is printed even without -w option.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-26 09:04:12 +00:00
stomar
9166fdac50
complex.c, object.c: [DOC] improve "exception: false" docs
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-24 20:41:15 +00:00
normal
9b9fe826fd
{complex,object,rational}.c: document exception: false
...
From: Victor Shepelev <zverok.offline@gmail.com>
[ruby-core:90673] [Bug #15452 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-22 22:39:31 +00:00
nobu
8ef2aae2d0
Use idException
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-22 10:23:06 +00:00
kazu
968fcd8346
[DOC] Update Object#=~ [ci skip]
...
see r65989
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-16 14:54:05 +00:00
nobu
973f84ef55
Show the class of the receiver [Feature #15231 ]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-06 23:03:54 +00:00
nobu
09ef29a78f
Prefer rb_check_arity when 0 or 1 arguments
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-05 01:09:44 +00:00
mame
ebff9dc10e
object.c: Deprecate Object#=~ and add NilClass#=~`
...
Object#=~ always returns nil. This behavior is not only unuseful but
also troublesome because it may hide a type error.
This change deprecates Object#=~. For compatibility, NilClass#=~ is
newly introduced. [Feature #15231 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-26 07:55:07 +00:00
k0kubun
38caab29bc
Always inline rb_to_integer to prevent a method call penalty
...
for integer types
Close https://github.com/ruby/ruby/pull/2001
Co-Authored-By: methodmissing <lourens@methodmissing.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-03 12:24:49 +00:00
stomar
905be736f7
object.c: [DOC] fix typos in doc for yield_self
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-26 12:19:04 +00:00
aycabta
d67b903519
Improve doc of yield_self
...
* object.c: Add code samples for yield_self.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-21 07:15:44 +00:00
nobu
e1966b31e9
Get rid of calling to_f in rat2dbl_without_to_f
...
[Bug #15189 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-02 18:03:43 +00:00
nobu
603f95a0ed
Fix Rational of Float
...
[ruby-core:89239] [Bug #15189 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-02 16:42:21 +00:00
nobu
02cae85e34
object.c: prefer base optarg
...
* object.c (rb_f_integer): prefer `base` optional argument over
keyword arguments. this issue should be resolved more generally
by separating keyword arguments from hashes in the future.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-22 16:03:58 +00:00
ko1
38e05ff3e1
Don't copy FL_USER* on Kernel#clone. [Bug #14847 ]
...
* object.c (mutable_obj_clone): `Kernel#clone` should not copy
FL_USER* flags because they are copied unexpectedly.
Unexpected copy will break internal data consistency.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-09 08:07:26 +00:00
matz
d53ee00891
object.c: Add a new alias `then` to `Kernel#yield_self`; [Feature #14594 ]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-30 08:24:52 +00:00
nobu
955849c126
object.c: raise on long invalid float string
...
* object.c (rb_cstr_to_dbl_raise): check long invalid float
string more precisely when truncating insignificant part.
[ruby-core:86800] [Bug #14729 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-04 06:12:12 +00:00
nobu
853707123e
object.c: fix exponent with underscore
...
* object.c (rb_cstr_to_dbl_raise): do not ignore exponent part
when the input string longer than internal buffer contains
underscore(s). [ruby-core:86836] [Bug #14731 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-02 13:37:18 +00:00
nobu
f852af0e59
symbol.c: non-ASCII constant names
...
* symbol.c (rb_sym_constant_char_p): support for non-ASCII
constant names. [Feature #13770 ]
* object.c (rb_mod_const_get, rb_mod_const_defined): support for
non-ASCII constant names.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-10 00:41:47 +00:00
mrkn
2993b4423d
Add `exception:` keyword in Kernel#Float()
...
Support `exception:` keyword argument in `Kernel#Float()`.
If `exception:` is `false`, `Kernel#Float()` returns `nil` if the given
value cannot be interpreted as a float value.
The default value of `exception:` is `true`.
This is part of [Feature #12732 ].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-15 07:19:45 +00:00
mrkn
2cfc5b03da
Add `exception:` keyword in Kernel#Integer()
...
Support `exception:` keyword argument in Kernel#Integer().
If `exception:` is `false`, `Kernel#Integer()` returns `nil` if the given
value cannot be interpreted as an integer value.
The default value of `exception:` is `true`.
This is part of [Feature #12732 ].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-15 07:19:43 +00:00