Граф коммитов

58538 Коммитов

Автор SHA1 Сообщение Дата
Yusuke Endoh 228ebdbf2f NEWS: fix a typo 2019-10-21 21:26:47 +09:00
Yusuke Endoh f364564e66 bignum.c (estimate_initial_sqrt): prevent integer overflow
`Integer.sqrt(0xffff_ffff_ffff_ffff ** 2)` caused assertion failure
because of integer overflow.  [ruby-core:95453] [Bug #16269]
2019-10-21 21:24:21 +09:00
Yusuke Endoh c8f97d1620 NEWS: structured the "Language changes" section
There were too many items in the section in somewhat random order.
This change creates the following five subsections:

* Pattern matching
* The spec of keyword arguments is changed towards 3.0
* Numbered parameter
* proc/lambda without no block is deprecated
* Other miscellaneous changes

Also it adds a handful of example code.
2019-10-21 18:46:54 +09:00
Nobuyoshi Nakada 5d63a9da40
[Bug #16121] adjusted indent [ci skip] 2019-10-21 17:45:27 +09:00
Dylan Thacker-Smith b970259044 Stop making a redundant hash copy in Hash#dup (#2489)
* Stop making a redundant hash copy in Hash#dup

It was making a copy of the hash without rehashing, then created an
extra copy of the hash to do the rehashing.  Since rehashing creates
a new copy already, this change just uses that rehashing to make
the copy.

[Bug #16121]

* Remove redundant Check_Type after to_hash

* Fix freeing and clearing destination hash in Hash#initialize_copy

The code was assuming the state of the destination hash based on the
source hash for clearing any existing table on it. If these don't match,
then that can cause the old table to be leaked. This can be seen by
compiling hash.c with `#define HASH_DEBUG 1` and running the following
script, which will crash from a debug assertion.

```ruby
h = 9.times.map { |i| [i, i] }.to_h
h.send(:initialize_copy, {})
```

* Remove dead code paths in rb_hash_initialize_copy

Given that `RHASH_ST_TABLE_P(h)` is defined as `(!RHASH_AR_TABLE_P(h))`
it shouldn't be possible for a hash to be neither of these, so there
is no need for the removed `else if` blocks.

* Share implementation between Hash#replace and Hash#initialize_copy

This also fixes key rehashing for small hashes backed by an array
table for Hash#replace.  This used to be done consistently in ruby
2.5.x, but stopped being done for small arrays in ruby 2.6.x.

This also bring optimization improvements that were done for
Hash#initialize_copy to Hash#replace.

* Add the Hash#dup benchmark
2019-10-21 17:29:21 +09:00
Koichi Sasada 8b8b9c1a1f add a NEWS entry about [Feature #15602] 2019-10-21 16:48:37 +09:00
Nobuyoshi Nakada 431132f037 Pass the called keyword arguments if `keyword_init` 2019-10-21 15:30:00 +09:00
git 215e4b8721 * expand tabs. [ci skip]
Tabs were expanded because previously the file did not have any tab indentation.
Please update your editor config, and use misc/expand_tabs.rb in the pre-commit hook.
2019-10-21 11:50:44 +09:00
Nobuyoshi Nakada 44da5a1c87
Look up event ID offsets by token as index 2019-10-21 11:45:54 +09:00
K.Takata 375124be51 st: Do error check only on non-Ruby 2019-10-21 11:14:36 +09:00
K.Takata e70e81b54e st: Add NULL checking
These are found by Coverity.
2019-10-21 11:14:36 +09:00
Nobuyoshi Nakada 263ee6639d
Make suggestions order stable [Bug #16263]
As the result order of `DidYouMean::SpellChecker#correct` is
undefined, keep the order of the original candidates.
2019-10-21 09:54:11 +09:00
MSP-Greg 71ffe40a44 test/optparse/test_did_you_mean.rb - fix suggestion order 2019-10-21 09:53:56 +09:00
Nobuyoshi Nakada 27261007eb
DidYouMean can be an empty stub module [Bug #16263] 2019-10-21 09:28:28 +09:00
git 1d29c9bd46 * 2019-10-21 [ci skip] 2019-10-21 09:11:47 +09:00
MSP-Greg 9223466752 test_exception - fix with & w/o did_you_mean
See Ruby issue 16263
2019-10-21 09:11:27 +09:00
Nobuyoshi Nakada ca7de0334d
Also BDOT2 and BDOT3 are operators 2019-10-20 20:45:56 +09:00
Koichi Sasada 9e07dfd253 show BASERUBY version at configure. 2019-10-20 16:16:54 +09:00
Koichi Sasada a236eaa762 Native MonitorMixin::ConditionVariable#wait
MonitorMixin::ConditionVariable#wait can be interrupted just after
Monitor#exit_for_cond. So implementation in C.
2019-10-20 15:45:30 +09:00
Koichi Sasada a0a3c70181 delegate synchronize method
Delegate MonitorMixin#synchronize body to Monitor#synchronize.
It makes guarantee interrupt safe (because Monitor#synchronize is
written in C). I thought Ruby implementation is also safe, but I
got stuck failure <http://ci.rvm.jp/results/trunk_test@P895/2327639>
so that I introduce this fix to guarantee interrupt safe.
2019-10-20 14:21:04 +09:00
Koichi Sasada caac5f777a
make monitor.so for performance. (#2576)
Recent monitor.rb has performance problem because of interrupt
handlers. 'Monitor#synchronize' is frequently used primitive
so the performance of this method is important.

This patch rewrite 'monitor.rb' with 'monitor.so' (C-extension)
and make it faster. See [Feature #16255] for details.

Monitor class objects are normal object which include MonitorMixin.
This patch introduce a Monitor class which is implemented on C
and MonitorMixin uses Monitor object as re-entrant (recursive)
Mutex. This technique improve performance because we don't need
to care atomicity and we don't need accesses to instance variables
any more on Monitor class.
2019-10-20 04:52:20 +09:00
git 434966bffd * 2019-10-20 [ci skip] 2019-10-20 02:58:58 +09:00
Nobuyoshi Nakada f2ed8466d3
Fixed a typo [ci skip] 2019-10-20 02:58:32 +09:00
Nobuyoshi Nakada 1d435bd51a
Extend Ripper DSL to set to pseudo variables other than `$$` 2019-10-19 17:19:27 +09:00
MSP-Greg 5c81e19b19 appveyor.yml - MinGW - update for MSYS2 / Mingw-w64 (#2573)
MSYS source code comes from both gcc.gnu.org & Mingw-w64.  Updates to the Mingw-w64 source broke the MinGW build step.

Fixes the issue until Mingw-w64 updates their source, then it should be reverted, see comments in code.
2019-10-18 11:03:54 -07:00
git 7dcc24fd81 * 2019-10-19 [ci skip] 2019-10-19 00:51:37 +09:00
Nobuyoshi Nakada bf934e4812
Fixed passing idNil as a Symbol 2019-10-19 00:50:17 +09:00
Nobuyoshi Nakada 9cb809cfef
Verbatim texts need more indent [ci skip]
And separate ruby script and executed example.
2019-10-18 22:18:52 +09:00
Kazuhiro NISHIYAMA 58e2ca31db
Use `_` instead of `_n_` 2019-10-18 20:24:36 +09:00
Yusuke Endoh ddad1fb229 NEWS: Mention that optparse now supports did_you_mean for unknown option 2019-10-18 17:53:17 +09:00
Nobuyoshi Nakada e2b719bed6
Support DidYouMean by AmbiguousOption too 2019-10-18 17:46:53 +09:00
Nobuyoshi Nakada b4d308b419
Defer adding additional info until getting the message of an error 2019-10-18 17:39:16 +09:00
Nobuyoshi Nakada e29e49abf0
Default DidYouMean.formatter to PlainFormatter 2019-10-18 16:43:40 +09:00
Nobuyoshi Nakada d4e52f672c
Added no suggestion test case 2019-10-18 15:19:26 +09:00
Nobuyoshi Nakada 46fa301e82
Use DidYouMean.formatter
Instead of building messages separately.
2019-10-18 15:18:36 +09:00
Nobuyoshi Nakada e50b8949fa
Suppress numbered parameter warnings 2019-10-18 14:59:26 +09:00
Nobuyoshi Nakada 095cdca15b
Make weakmap finalizer an ifunc lambda
Simple comparison between proc/ifunc/method invocations:

```
  proc     15.209M (± 1.6%) i/s -     76.138M in   5.007413s
 ifunc     15.195M (± 1.7%) i/s -     76.257M in   5.020106s
method      9.836M (± 1.2%) i/s -     49.272M in   5.009984s
```

As `proc` and `ifunc` have no significant difference, chosen the
latter for arity check.
2019-10-18 14:53:52 +09:00
Nobuyoshi Nakada ce7942361d
Use identhash as WeakMap
As ObjectSpace::WeakMap allows FLONUM as a key, needs the special
deal for its hash.  [Feature #16035]
2019-10-18 14:53:51 +09:00
Yusuke Endoh c3b64a86bc lib/optparse.rb: Show a did_you_mean hint for unknown option
```
require 'optparse'

OptionParser.new do |opts|
  opts.on("-f", "--foo", "foo") {|v| }
  opts.on("-b", "--bar", "bar") {|v| }
  opts.on("-c", "--baz", "baz") {|v| }
end.parse!
```

```
$ ruby test.rb --baa
Traceback (most recent call last):
test.rb:7:in `<main>': invalid option: --baa (OptionParser::InvalidOption)
Did you mean?  baz
               bar
```
2019-10-18 12:20:58 +09:00
Seiei Miyagi 5ca5529d22 Fix warning of generated parser for nested module 2019-10-17 19:23:50 -07:00
Aaron Patterson 1d564acedc
Remove unused constant.
This constant isn't used, so lets remove it.
2019-10-17 13:35:26 -07:00
Aaron Patterson 9026e12f93
Look up constant instead of caching in a global
The global can go bad if the compactor runs, so we need to look up the
constant instead of caching it in a global.
2019-10-17 13:30:09 -07:00
Jeremy Evans ee821e9074 Update test to handle x32 ABI compiled Ruby on Linux
Suggestion from Laurence Parry.

Fixes [Bug #16030]
2019-10-17 12:21:47 -07:00
aycabta 8c0629ba58 Treat key sequences from getwch() that start from 0 or 0xE0 correctly 2019-10-18 02:54:20 +09:00
aycabta 58657fa134 Add numeric keypad key sequences on Windows 2019-10-18 02:54:20 +09:00
aycabta 53c05a6cf4 Remove freeze 2019-10-18 02:54:20 +09:00
aycabta 13b106a19c Ignore the input method key sequence from getwch() correctly
The function getwch() returns some key sequences which start from 0 or 0xE0
with a following key code. Alt+` that is on/off key for input methods gives 0
and 41 so Reline was always ignoring 0 and following keys but numeric keypad
keys give 0 and following actual keys. This commit changes the behavior to be
ignoring only the 0 and 41 sequence.
2019-10-18 02:54:20 +09:00
Jeremy Evans 0162e7e647 Make circular argument reference a SyntaxError instead of a warning
Fixes [Bug #10314]
2019-10-17 09:32:06 -07:00
git fdfb5100b9 * 2019-10-18 [ci skip] 2019-10-18 00:46:02 +09:00
aycabta d1a7305848 Insert multiline incremental search result correctly 2019-10-18 00:44:56 +09:00