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

13139 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada fcd8bafd08
Use a temporary file for chown test
Errno::EROFS may occur when the source tree is placed in a
read-only filesystem.
2019-12-18 13:35:58 +09:00
Nobuyoshi Nakada c147eeff7c [ruby/io-console] Skip Interrupt test on Linux
Hangs up only in ruby/ruby on Travis-CI.

https://github.com/ruby/io-console/commit/de39aa6dd6
2019-12-18 13:30:52 +09:00
Nobuyoshi Nakada 77e3078ede [ruby/io-console] Set raw mode strictly same as cfmakeraw
* Default VMIN and VTIME to minimum input.
* Disable parity check bits explicitly.
* Disable all bits for flow control on input.

Co-Authored-By: NARUSE, Yui <naruse@airemix.jp>

https://github.com/ruby/io-console/commit/5ce201a686
2019-12-18 10:33:05 +09:00
Nobuyoshi Nakada bcec03af05
Revert "Skip interruptible raw mode test on Travis-CI"
This reverts commit 65731a1330.
2019-12-18 00:08:21 +09:00
Nobuyoshi Nakada 07ed8f2f91 [ruby/io-console] Skip interrupt
https://github.com/ruby/io-console/commit/8ed5a2bcc3
2019-12-18 00:08:04 +09:00
Nobuyoshi Nakada 905a926ea8 [ruby/io-console] Timeout in the child process
https://github.com/ruby/io-console/commit/b8411689a5
2019-12-17 23:55:24 +09:00
Nobuyoshi Nakada 4b7d27ca0d [ruby/io-console] Use IO.console instead of STDIN
https://github.com/ruby/io-console/commit/9e3ec5b936
2019-12-17 23:55:22 +09:00
Nobuyoshi Nakada 65731a1330
Skip interruptible raw mode test on Travis-CI 2019-12-17 17:18:42 +09:00
Nobuyoshi Nakada 9421c78041
[ruby/logger] Fixed leaked tempfile
https://github.com/ruby/logger/commit/fb3eff153f
2019-12-17 14:01:40 +09:00
Nobuyoshi Nakada 81eb2d16ef
[ruby/io-console] Disable implementation-defined special control characters
In raw mode with interrupt enabled.

https://github.com/ruby/io-console/commit/e9e8e3ff17
2019-12-17 13:55:04 +09:00
Nobuyoshi Nakada ec89a0f803
[ruby/io-console] Added the test for intr option
https://github.com/ruby/io-console/commit/4f01db102d
2019-12-17 13:55:04 +09:00
aycabta 64ce658ec5 Fix return condition according to the condition to skip 2019-12-17 13:30:54 +09:00
aycabta 618d091151 Support change search direction 2019-12-17 13:10:39 +09:00
aycabta a14a0244b4 Support forward-search-history by C-s 2019-12-17 13:07:19 +09:00
Nobuyoshi Nakada c687be4bc0
Added a test for [Bug #16159] 2019-12-17 11:53:30 +09:00
aycabta 95213f6df6 Check wether Readline.completion_append_character= exists 2019-12-17 05:08:09 +09:00
Yusuke Endoh bba6386d95 test/ruby/test_process.rb: suppress "unused variable" warning 2019-12-17 00:44:53 +09:00
Richard Viney 6a75a46053
Make prettyprint’s cycle detection aware of Delegator instances
Fixes [Bug #13144]

Co-Authored-By: Nobuyoshi Nakada <nobu@ruby-lang.org>
2019-12-16 23:43:49 +09:00
Yusuke Endoh 251f5d8226 Revert "lib/net/http/response.rb: support raw deflate correctly"
This reverts commit 5105240b1e.

In RFC 2616:

```
   deflate
        The "zlib" format defined in RFC 1950 [31] in combination with
        the "deflate" compression mechanism described in RFC 1951 [29].
```

So "Content-Encoding: deflate" means zlib format, not raw deflate.

[Bug #11268]
2019-12-16 23:39:10 +09:00
Yusuke Endoh 5105240b1e lib/net/http/response.rb: support raw deflate correctly
Net::HTTP had used `Zlib::Inflate.new(32 + Zlib::MAX_WBITS)` for all
content encoding (deflate, zlib, and gzip).
But the argument `32 + Zlib::MAX_WBITS` means zlib and gzip decoding
with automatic header detection, so (raw) deflate compression had not
been supported.

This change makes it support raw deflate correctly by passing an
argument `-Zlib::MAX_WBITS` (which means raw deflate) to
`Zlib::Inflate.new`.  All deflate-mode tests are fixed too.

[Bug #11268]
2019-12-16 23:20:42 +09:00
Nobuyoshi Nakada d2f04d332f Kernel#abort without arguments should print error info
[Bug #16424]
2019-12-16 14:55:59 +09:00
Nobuyoshi Nakada e8c62836a6
IO#set_encoding_by_bom should err when encoding is already set
Except for ASCII-8BIT.  [Bug #16422]
2019-12-15 23:13:16 +09:00
Kazuhiro NISHIYAMA a83c46e3fd
Add more debug info
closed server doesn't have useful info.
So call inspect before close.
And add local debug code in comment.

https://rubyci.org/logs/rubyci.s3.amazonaws.com/unstable11x/ruby-master/log/20191215T092405Z.fail.html.gz
```
  1) Failure:
IMAPTest#test_connection_closed_without_greeting [/export/home/rubyci/chkbuild-tmp/tmp/build/20191215T092405Z/ruby/test/net/imap/test_imap.rb:483]:
[Net::IMAP::Error] exception expected, not #<RuntimeError: {:e=>#<Errno::EINVAL: Invalid argument - connect(2) for [::1]:41748>, :server=>#<TCPServer:(closed)>, :port=>41748, :server_addr=>"::1"}>.
```
2019-12-15 20:09:24 +09:00
Hiroshi SHIBATA 980ddca47e
Prepare to release rubygems-3.1.0 2019-12-15 16:48:52 +09:00
Kazuhiro NISHIYAMA e2b192f7d5
rand(beginless_range) raise Errno::EDOM instead of TypeError
same as `rand(endless_range)`

Before:
```
$ ruby -e 'rand(..1)'
Traceback (most recent call last):
	2: from -e:1:in `<main>'
	1: from -e:1:in `rand'
-e:1:in `-': nil can't be coerced into Integer (TypeError)
```

After:
```
$ ruby -e 'rand(..1)'
Traceback (most recent call last):
	1: from -e:1:in `<main>'
-e:1:in `rand': Numerical argument out of domain (Errno::EDOM)
```
2019-12-15 14:47:36 +09:00
Nobuyoshi Nakada 84b873e381 [ruby/irb] Restore environment variables
https://github.com/ruby/irb/commit/236590882c
2019-12-14 00:39:53 +09:00
Hiroshi SHIBATA ab1f3d63b0
Fixed a typo 2019-12-13 22:10:28 +09:00
Hiroshi SHIBATA 2ef5f012c1
Added explicitly loading `Gem::Command` class 2019-12-13 22:00:28 +09:00
Nobuyoshi Nakada 6183addf6a Add `Warning.[]` and `Warning.[]=` 2019-12-13 20:47:07 +09:00
Hiroshi SHIBATA 82cc2843a9
Prepare to release RubyGems 3.1.0 final version. 2019-12-13 20:19:33 +09:00
aycabta c2dfc6d869 Show a menu before a document
IRB should show a menu first if a completed list has plural items. But just
shows document without menu if a completed list with plural items includes a
perfect matched item. The behavior is a bug. This commit fixes it.
2019-12-13 08:54:22 +09:00
Nobuyoshi Nakada b8d6c883b3
Improved the test for Thread#inspect [Feature #16412] 2019-12-13 08:52:07 +09:00
aycabta 69b6f8fd04 Check wether TestReadline is defined 2019-12-13 00:04:44 +09:00
Kazuhiro NISHIYAMA 68321dd1fa
Move `rescue` for debug into block of assert_raise 2019-12-12 22:05:14 +09:00
Nobuyoshi Nakada dd60856f8d
[cygwin] fix File.absolute_path? test
Paths start with the root are absolute on cygwin, regardless the
drive letter.
2019-12-12 20:53:59 +09:00
Nobuyoshi Nakada b6f25318c5
Cygwin path cannot be mapped to a UNC as-is 2019-12-12 20:53:02 +09:00
Kazuhiro NISHIYAMA c20dd2f754
Add more debug info when Errno::EINVAL
https://rubyci.org/logs/rubyci.s3.amazonaws.com/unstable11x/ruby-master/log/20191212T072406Z.fail.html.gz
2019-12-12 17:38:27 +09:00
Jeremy Evans 55b7ba3686 Make super in instance_eval in method in module raise TypeError
This makes behavior the same as super in instance_eval in method
in class.  The reason this wasn't implemented before is that
there is a check to determine if the self in the current context
is of the expected class, and a module itself can be included
in multiple classes, so it doesn't have an expected class.

Implementing this requires giving iclasses knowledge of which
class created them, so that super call in the module method
knows the expected class for super calls.  This reference
is called includer, and should only be set for iclasses.

Note that the approach Ruby uses in this check is not robust. If
you instance_eval another object of the same class and call super,
instead of an TypeError, you get super called with the
instance_eval receiver instead of the method receiver.  Truly
fixing super would require keeping a reference to the super object
(method receiver) in each frame where scope has changed, and using
that instead of current self when calling super.

Fixes [Bug #11636]
2019-12-12 15:50:19 +09:00
Hiroshi SHIBATA 53e8589c69
Import json-2.3.0 from flori/json 2019-12-12 09:14:09 +09:00
aycabta 7d991a0571 Suppress to crash IRB if completed list has nil 2019-12-12 08:40:50 +09:00
aycabta 51cc5a26df Some tests failed with before GNU Readline 6.0 on Windows 2019-12-12 03:19:09 +09:00
Jeremy Evans 0dcd3340fb
[ruby/forwardable] Make def_*_delegator return name of method defined (Fixes #10)
This restores compatibility with previous versions.  This behavior
was previously undefined, but it makes sense for the name of the
defined method to be returned.

https://github.com/ruby/forwardable/commit/a52ef3451e
2019-12-11 20:23:53 +09:00
aycabta c2f6aa4e48 The result of Readline.completion_proc should have the same encoding of Encoding.default_external 2019-12-11 19:39:37 +09:00
Koichi Sasada eb9c007053 skip continuous failure test.
On mingw this test fails and not solved long time, so skip it.
Please revert it when it solved.

https://ci.appveyor.com/project/ruby/ruby/builds/29458671/job/9nbcjnfe6p0xnxoe
2019-12-11 16:49:08 +09:00
Kazuhiro NISHIYAMA cf948a3d3f Do not load q.rb in build directory 2019-12-11 12:35:51 +09:00
Kazuhiro NISHIYAMA 1ed0212bcf Do not load files in build directory
related https://bugs.ruby-lang.org/issues/16177
2019-12-11 12:35:51 +09:00
Jeremy Evans 85e43e1dfe Fix Enumerator::Lazy#with_index
* Make it correctly handle lambdas
* Make it iterate over the block if block is given

The original implementation was flawed, based on lazy_set_method
instead of lazy_add_method.

Note that there is no implicit map when passing a block, the return
value of the block passed to with_index is ignored, just as it
is for Enumerator#with_index. Also like Enumerator#with_index,
when called with a block, the return value is an enumerator without
the index.

Fixes [Bug #16414]
2019-12-11 04:59:56 +02:00
Hiroshi SHIBATA 2a2a707829
Followed up 38722fa179 2019-12-10 21:21:19 +09:00
Jeremy Evans 0b10d46a57 [ruby/logger] Enable more timezone tests on OpenBSD
https://github.com/ruby/logger/commit/bcd7e227e8
2019-12-10 21:01:11 +09:00
Jeremy Evans 38722fa179 [ruby/logger] Raise ArgumentError for invalid shift_age
Consider 'now' and 'everytime' as valid values for the previous
behavior of rotating everytime.

Fixes Ruby Bug 15977

https://github.com/ruby/logger/commit/f92979a376
2019-12-10 20:59:02 +09:00
George Claghorn eb18cb3e47 [ruby/logger] Honor Logger#level overrides
https://github.com/ruby/logger/commit/7365c995bf
2019-12-10 20:58:25 +09:00
NARUSE, Yui af11efd377 fix ipaddr parameter of Net::HTTP.start to support proxy
54072e329c
2019-12-10 19:12:21 +09:00
Hiroshi SHIBATA 79d2a1b004
Update regression tests for 1.4.16 2019-12-10 18:41:05 +09:00
Kazuhiro NISHIYAMA 7be550d046
Stop Thread.new in `DRb::TimerIdConv::TimerHolder2#on_gc`
and add more stop_pool after stop_service
2019-12-10 12:43:49 +09:00
Yusuke Endoh c50d9dc67d test/ruby/test_keywords.rb: suppress a warning
https://rubyci.org/logs/rubyci.s3.amazonaws.com/ubuntu1604/ruby-master/log/20191210T003005Z.log.html.gz
```
.../test/ruby/test_keyword.rb:2711: warning: `*' interpreted as argument prefix
```
2019-12-10 11:26:22 +09:00
Yusuke Endoh 660388f6c5 test/net/http/test_https.rb (test_get_SNI_failure): stop proxy settings
Because the test fails under HTTP proxy settings.

https://rubyci.org/logs/rubyci.s3.amazonaws.com/solaris10-gcc/ruby-master/log/20191210T000004Z.fail.html.gz
```
  1) Failure:
TestNetHTTPS#test_get_SNI_failure [/export/home/users/chkbuild/cb-gcc/tmp/build/20191210T000004Z/ruby/test/net/http/test_https.rb:81]:
[OpenSSL::SSL::SSLError] exception expected, not #<Net::HTTPServerException: 403 "Forbidden">.
```

The new SNI feature introduced at 54072e329c may need to be improved for
HTTP proxy environment.
2019-12-10 09:41:33 +09:00
aycabta 6a22b2a091 Support completion with case-insensitive fashion
Reline performs completion in a case-insensitive fashon if
Readline.completion_case_fold or completion-ignore-case of .inputrc are set
"on".
2019-12-10 07:07:43 +09:00
Jeremy Evans f45c0dc239 Add Proc#ruby2_keywords
This allows passing keywords through a normal argument splat in a
Proc.  While needing ruby2_keywords support for methods is more
common, there is code that delegates keywords through normal
argument splats in procs, including code in Rails.  For that
reason, it makes sense to expose this for procs as well.

Internally, ruby2_keywords is not tied to methods, but iseqs,
so this just allows for setting the ruby2_keywords for the iseq
related to the proc.
2019-12-09 17:10:19 +02:00
NARUSE, Yui 54072e329c Add ipaddr optional parameter to Net::HTTP#start
to replace the address for TCP/IP connection [Feature #5180]

There're 3 layers of hostname:
* host address for TCP/IP
* TLS server name
* HTTP Host header value
To test DNS round robin or check server certificate from server local,
people sometimes want to connect server with given IP address but keep
TLS server name and HTTP Host header value.

closes [Feature #15215]
closes https://github.com/ruby/ruby/pull/1893
closes https://github.com/ruby/ruby/pull/1977
2019-12-09 20:21:49 +09:00
Hiroshi SHIBATA 1943279426
Added workaround for CoreAssertions used by ruby/logger. 2019-12-09 19:17:32 +09:00
Hiroshi SHIBATA 4b36832ba6
Merge the upstream changes for test-unit on ruby/logger.
This commits are based with:
    f067f7d1aa
    86058f420d
    02db6e8ed8
2019-12-09 19:17:32 +09:00
aycabta 07664f3aec Remove workaround encoding modification 2019-12-09 14:21:20 +09:00
Kazuhiro NISHIYAMA 8b07c122b7
Stop pool threads in test/rinda too 2019-12-09 13:46:23 +09:00
aycabta 0d63a21047 Skip completion tests for Editline 2019-12-08 18:29:39 +09:00
aycabta c38bc172be Fix encoding of completed list 2019-12-08 08:35:31 +09:00
aycabta c9b06d4a4e Add test_simple_completion for Readline 2019-12-08 08:01:27 +09:00
Yusuke Endoh ebbc77836b test/ruby/test_file_exhaustive.rb: shorten the name of temporary dir
```
  1) Error:
TestFileExhaustive#test_socket_p:
ArgumentError: too long unix socket path (109bytes given but 108bytes max)
    /export/home/users/chkbuild/cb-sunc/tmp/build/20191207T024036Z/ruby/test/ruby/test_file_exhaustive.rb:155:in `initialize'
```
2019-12-07 13:16:41 +09:00
Kazuhiro NISHIYAMA 2f6a8baac6
Test interfaces include localhost
When interfaces do not include localhost,
some other tests may fail.
2019-12-06 16:03:16 +09:00
Kazuhiro NISHIYAMA 693cba1a13
Detect started threads when require only 2019-12-06 00:12:58 +09:00
Yusuke Endoh 6477d98e49 test/lib/jit_support.rb: Update the regexp for icc
MJIT_CC is always an absolute path.
2019-12-05 23:46:42 +09:00
Yusuke Endoh 0bca34ddaa test/io/console/test_io_console.rb: add a memo for the mysterious hack 2019-12-05 16:56:08 +09:00
aycabta 264d5aff5a Change encoding of completion list...for more tests 2019-12-05 16:29:47 +09:00
Yusuke Endoh b40bb27e35 test/io/console/test_io_console.rb: Try the hack for Solaris
I'm not entirely sure why, but test_set_winsize_console gets stuck on
Solaris (and if I recall, macOS).  I found a hack for FreeBSD, so I want
to give it a try on Solaris too.
2019-12-05 15:53:29 +09:00
Takashi Kokubun 5fbb4555b4
Prefer using MJIT_CC for JIT support check
because Solaris might have CC=cc and we'd like to check full path
MJIT_CC=/opt/developerstudio12.5/bin/cc instead.
2019-12-04 22:16:08 -08:00
Koichi Sasada edb80dfe3e add additional CF info for CI env
Introduce new RUBY_DEBUG option 'ci' to inform Ruby interpreter
that an interpreter is running on CI environment.

With this option, `rb_bug()` shows more information includes
method entry information, local variables information for each
control frame.
2019-12-05 14:47:31 +09:00
Jun Aruga c0d118f41a Fix "cannot find the function: strcpy()" error on arm32 on Travis CI. (#2686)
This issue happened when `libc.so` and `libm.so` path were not found
and `ldd ruby` command also failed to print the shared dependencies
in `test/fiddle/helper.rb`.

See https://travis-ci.org/ruby/ruby/jobs/611483288#L3018
/home/travis/build/ruby/ruby/build/.ext/common/fiddle/import.rb:299:in `import_function': cannot find the function: strcpy() (Fiddle::DLError)

* Set libc6:armhf as a installing dependency explicitly.
* Remove arm32 from allow_failures.
2019-12-05 14:17:16 +09:00
aycabta 20031f8b74 Change encoding of completion list 2019-12-05 13:06:18 +09:00
Alan Wu df76f2c577
Make TracePoint.stat a singleton method again (#2726)
[Bug #16399]
2019-12-04 21:02:21 -05:00
Kazuhiro NISHIYAMA 88ee375dd6
Revert "Add debug option to check ci failures on solaris"
This reverts commit f289e3994b.
2019-12-05 09:44:09 +09:00
aycabta e3587ed849 Support disable-completion 2019-12-05 09:02:23 +09:00
aycabta ad8fbf444a Fix variable catch 2019-12-05 09:02:23 +09:00
Kazuhiro NISHIYAMA a0bc0e1ba1 Fix thread leak in drb 2019-12-04 20:57:24 +09:00
卜部昌平 00bbdf4451 implement Range#count
As matz requested in [Bug #16366].
2019-12-04 15:32:49 +09:00
Koichi Sasada c6e3db0c66 new_cond before mon_initialize
MonitorMixin#new_cond can be called before mon_initialize, so we
need to initialize `@monitor` before it.

https://bugs.ruby-lang.org/issues/16255#note-4
2019-12-04 13:36:41 +09:00
Yusuke Endoh f9e5c74cd2 compile.c: stop wrong peephole optimization when covearge is enabled
jump-jump optimization ignores the event flags of the jump instruction
being skipped, which leads to overlook of line events.

This changeset stops the wrong optimization when coverage measurement is
neabled and when the jump instruction has any event flag.

Note that this issue is not only for coverage but also for TracePoint,
and this change does not fix TracePoint.
However, fixing it fundamentally is tough (which requires revamp of
the compiler).  This issue is critical in terms of coverage measurement,
but minor for TracePoint (ko1 said), so we here choose a stopgap
measurement.

[Bug #15980] [Bug #16397]

Note for backporters: this changeset can be viewed by `git diff -w`.
2019-12-04 10:40:54 +09:00
Jeremy Evans a91637c516 Make {Method,UnboundMethod}#super_method handle clone/bind/unbind
This wasn't working previously because the iclass entry wasn't
being copied, and without an iclass entry, super_method returns
nil.

Fixes [Bug #15629]
2019-12-04 01:35:34 +02:00
NARUSE, Yui 8852fa8760 Revert "Regexp#match{?} with nil raises TypeError as String, Symbol (#1506)"
This reverts commit 2a22a6b2d8.
Revert [Feature #13083]
2019-12-04 06:40:54 +09:00
NARUSE, Yui 08074eb712 Revert "Revert nil error and adding deprecation message"
This reverts commit 452bee3ee8.
2019-12-04 06:40:54 +09:00
Jeremy Evans a029b54ec7 Make Enumerator::Chain#each treat lambdas as lambda
Previously, lambdas were converted to procs because of how
rb_block_call works.  Switch to rb_funcall_with_block, which
handles procs as procs and lambdas as lambdas.

Fixes [Bug #15613]
2019-12-03 23:18:28 +02:00
Jeremy Evans 47c97e1e84 Do not lose existing constant visibility when autoloading
This copies the private/deprecate constant visibility across the
autoload.  It still is backwards compatible with setting the
private/deprecate constant visibility in the autoloaded file.
However, if you explicitly set public constant in the autoloaded
file, that will be reset after the autoload.

Fixes [Bug #11055]
2019-12-03 17:31:49 +02:00
Nobuyoshi Nakada 14a17063a1
Fixed stack overflow [Bug #16382]
Get rid of infinite recursion in expanding a load path to the real
path while loading a transcoder.
2019-12-03 08:51:50 +09:00
aycabta a92560132b Support incremental search by last determined word
In the incremental search by C-r, search word is saved when it's determined. In
the next incremental search by C-r, if a user presses C-r again with the empty
search word, the determined previous search word is used to search.
2019-12-03 01:39:59 +09:00
Kazuhiro NISHIYAMA 1a88adcd75 Fix Leaked file descriptor in test/did_you_mean
de74d2c3b0/checks?check_suite_id=336910877#step:19:131
```
Leaked file descriptor: NameErrorExtensionTest#test_correctable_error_objects_are_dumpable: 7 : #<File:test_name_error_extension.rb>
```
2019-12-02 16:25:43 +09:00
Nobuyoshi Nakada b1c92363a7
Wait for the main thread to start reading by Queue
Otherwise, the written data to pty before the reading started may
be just lost.
2019-12-02 13:17:05 +09:00
aycabta 103b04128f Support incremental search again by C-r in incremental search 2019-12-02 04:18:22 +09:00
Takashi Kokubun b3ea0980db
Check MJIT support in one place
to fix test failure on trunk-no-mjit
https://gist.github.com/ko1/32ab982ffd7555988818773c08f97123
2019-12-01 10:53:59 -08:00
Takashi Kokubun 6bc8b4d8ea
Skip --jit-debug= test on mswin
it fails like
https://ci.appveyor.com/project/ruby/ruby/builds/29235837/job/v0apdjj4qx8afars
2019-12-01 10:51:05 -08:00
aycabta e15b0313a7 Search history to back in the middle of histories 2019-12-02 03:09:41 +09:00
aycabta 7f0d51704a Remove obsolete code 2019-12-02 00:03:59 +09:00
aycabta 8cb3f29abf The ed_search_prev_history should always search to backward 2019-12-01 23:54:57 +09:00
Takashi Kokubun 3e2753ad2e
Use build dir for testing --jit-debug
to fix failure like https://github.com/ruby/ruby/runs/327745536
2019-12-01 01:25:55 -08:00
Takashi Kokubun a19d625e66
Allow specifying arbitrary MJIT flags by --jit-debug
This is a secret feature for me. It's only for testing and any behavior
with this flag override is unsupported.

I needed this because I sometimes want to add debug options but do not
want to disable optimizations, for using Linux perf.
2019-12-01 00:58:47 -08:00
Yuki Nishijima 9914d6e992 Relax test strictness for error message from KeyError 2019-11-30 23:26:09 -05:00
Yuki Nishijima cc7455dd1e Relax test requirements for DYM's verbose formatter 2019-11-30 22:29:02 -05:00
Koichi Sasada 56faa13a1c remove spaces to pass a test.
23d7f4c5e1 breaks a test which expect
to match error message. To avoid this failure, use #strip for expect
and actual results.
2019-12-01 12:24:50 +09:00
git 23d7f4c5e1 * remove trailing spaces. [ci skip] 2019-12-01 11:08:39 +09:00
Kevin Deisz 171803d5d3 Promote did_you_mean to default gem
At the moment, there are some problems with regard to bundler + did_you_mean because of did_you_mean being a bundled gem. Since the vendored version of thor inside bundler and ruby itself explicitly requires did_you_mean, it can become difficult to load it when using Bundler.setup. See this issue: https://github.com/yuki24/did_you_mean/issues/117#issuecomment-482733159 for more details.
2019-11-30 21:08:19 -05:00
Nobuyoshi Nakada 5e0479f26a ENV.update should not call block on existing keys
[Bug #16192]
2019-11-30 18:18:20 +01:00
Hiroshi SHIBATA 32e547954f
Revert "[ruby/fileutils] Fix #install with "X" mode option"
This reverts commit eab88d20ea.

  The some CI was broken with this.
2019-11-30 17:58:39 +09:00
Nobuyoshi Nakada 5e9f08647c [ruby/webrick] Check the feature by itself, instead of the version number
https://github.com/ruby/webrick/commit/79d7922de9
2019-11-30 17:52:05 +09:00
Jeremy Evans a98632d5c2 [ruby/webrick] Enabled chunked encoding if Transfer-Encoding: chunked header is set
Patch from Leonard Garvey.

Fixes Ruby Bug 9986.

https://github.com/ruby/webrick/commit/8cff7f3995
2019-11-30 17:50:13 +09:00
Jeremy Evans c75100d004 [ruby/webrick] Allow WEBrick::HTTPServlet::CGIHandler :CGIInterpreter option to be array
This way you don't need to escape each entry.

Implements Ruby Feature 15170.

https://github.com/ruby/webrick/commit/d8086e600c
2019-11-30 17:48:15 +09:00
Nobuyoshi Nakada eab88d20ea [ruby/fileutils] Fix #install with "X" mode option
`FileUtils#install` methed raises an unexpected `TypeError`, when
called with `mode:` option which has `"X"`.

```
$ ruby -rfileutils -e 'FileUtils.install("tmp/a", "tmp/b", mode: "o+X")'
/opt/local/lib/ruby/2.7.0/fileutils.rb:942:in `directory?': no implicit conversion of File::Stat into String (TypeError)
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:942:in `block (3 levels) in symbolic_modes_to_i'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:933:in `each_char'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:933:in `each'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:933:in `inject'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:933:in `block (2 levels) in symbolic_modes_to_i'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:931:in `each'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:931:in `each_slice'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:931:in `block in symbolic_modes_to_i'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:926:in `each'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:926:in `inject'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:926:in `symbolic_modes_to_i'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:973:in `fu_mode'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:883:in `block in install'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:1588:in `block in fu_each_src_dest'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:1604:in `fu_each_src_dest0'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:1586:in `fu_each_src_dest'
	from /opt/local/lib/ruby/2.7.0/fileutils.rb:877:in `install'
	from -e:1:in `<main>'
```

In spite of that `symbolic_modes_to_i` considers the `File::Stat`
`path` case at the beginning, in `"X"` case, `path` is passed to
`FileTest.directory?` method which requires a `String`.  In such
case, the mode in `path` should be examined instead.

https://github.com/ruby/fileutils/commit/2ea54ade2f
2019-11-30 17:31:35 +09:00
Nobuyoshi Nakada aab74fc938 [ruby/fileutils] Added `test_install_mode_option`
https://github.com/ruby/fileutils/commit/bb10efe104
2019-11-30 17:31:05 +09:00
Jeremy Evans 9fa0166a58 [ruby/forwardable] Fix keyword argument separation warnings on Ruby 2.7+
Do so in a way that is also compatible with previous versions.

https://github.com/ruby/forwardable/commit/b2dd340988
2019-11-30 15:53:42 +09:00
Jeremy Evans 0c273b2279 Supress class variable overtaken warning when original modules are the same
This issue was exposed by recent commits to better support including
refined modules.
2019-11-29 20:32:03 +02:00
Nobuyoshi Nakada d1ef4fd08e
Make single line pattern matching void expression
Instead of returning `nil`, raise a syntax error if its value is
used.  [Feature #16355]
2019-11-30 00:15:29 +09:00
Koichi Sasada 36da0b3da1 check interrupts at each frame pop timing.
Asynchronous events such as signal trap, finalization timing,
thread switching and so on are managed by "interrupt_flag".
Ruby's threads check this flag periodically and if a thread
does not check this flag, above events doesn't happen.

This checking is CHECK_INTS() (related) macro and it is placed
at some places (laeve instruction and so on). However, at the end
of C methods, C blocks (IMEMO_IFUNC) etc there are no checking
and it can introduce uninterruptible thread.

To modify this situation, we decide to place CHECK_INTS() at
vm_pop_frame(). It increases interrupt checking points.
[Bug #16366]

This patch can introduce unexpected events...
2019-11-29 17:47:02 +09:00
Yusuke Endoh 191ce5344e Reduce duplicated warnings for the change of Ruby 3 keyword arguments
By this change, the following code prints only one warning.

```
def foo(**opt); end
100.times { foo({kw:1}) }
```

A global variable `st_table *caller_to_callees` is a map from caller to
a set of callee methods.  It remembers that a warning is already printed
for each pair of caller and callee.

[Feature #16289]
2019-11-29 17:32:27 +09:00
Yusuke Endoh 3a87826d0c vm_method.c: add top-level ruby2_keywords
This is a top-level version of Module#ruby2_keywords.
It can be used for functions (top-level methods) that delegates
arguments.  [Feature #16364]
2019-11-29 16:51:13 +09:00
Nobuyoshi Nakada 5ad32d5504
`LoadError` is not a subclass of `StandardError` 2019-11-29 11:25:23 +09:00
Nobuyoshi Nakada f83bebdf7a
Skip useless test
`JSONGeneratorTest#test_remove_const_seg` is meaningful only for
the extension library version, but nonsense for pure ruby version.
2019-11-29 11:21:38 +09:00
git d104ebf2c4 * remove trailing spaces. [ci skip] 2019-11-29 03:11:28 +09:00
Koichi Sasada dd723771c1 fastpath for ivar read of FL_EXIVAR objects.
vm_getivar() provides fastpath for T_OBJECT by caching an index
of ivar. This patch also provides fastpath for FL_EXIVAR objects.
FL_EXIVAR objects have an each ivar array and index can be cached
as T_OBJECT. To access this ivar array, generic_iv_tbl is exposed
by rb_ivar_generic_ivtbl() (declared in variable.h which is newly
introduced).

Benchmark script:

Benchmark.driver(repeat_count: 3){|x|
  x.executable name: 'clean', command: %w'../clean/miniruby'
  x.executable name: 'trunk', command: %w'./miniruby'

  objs = [Object.new, 'str', {a: 1, b: 2}, [1, 2]]

  objs.each.with_index{|obj, i|
    rep = obj.inspect
    rep = 'Object.new' if /\#/ =~ rep
    x.prelude str = %Q{
      v#{i} = #{rep}
      def v#{i}.foo
        @iv # ivar access method (attr_reader)
      end
      v#{i}.instance_variable_set(:@iv, :iv)
    }
    puts str
    x.report %Q{
      v#{i}.foo
    }
  }
}

Result:

      v0.foo # T_OBJECT

               clean:  85387141.8 i/s
               trunk:  85249373.6 i/s - 1.00x  slower

      v1.foo # T_STRING

               trunk:  57894407.5 i/s
               clean:  39957178.6 i/s - 1.45x  slower

      v2.foo # T_HASH

               trunk:  56629413.2 i/s
               clean:  39227088.9 i/s - 1.44x  slower

      v3.foo # T_ARRAY

               trunk:  55797530.2 i/s
               clean:  38263572.9 i/s - 1.46x  slower
2019-11-29 03:11:04 +09:00
NARUSE, Yui b5fbefbf2c Added Symbol#start_with? and Symbol#end_with? method. [Feature #16348] 2019-11-28 23:49:28 +09:00
Jeremy Evans a0579f3606 Make prepending a refined module after inclusion not break refinements
After the previous commit, this was still broken. The reason it
was broken is that a refined module that hasn't been prepended to
yet keeps the refined methods in the module's method table. When
prepending, the module's method table is moved to the origin
iclass, and then the refined methods are moved from the method
table to a new method table in the module itself.

Unfortunately, that means that if a class has included the module,
prepending breaks the refinements, because when the methods are
moved from the origin iclass method table to the module method
table, they are removed from the method table from the iclass
created when the module was included earlier.

Fix this by always creating an origin class when including a
module that has any refinements, even if the refinements are
not currently used.  I wasn't sure the best way to do that.
The approach I choose was to use an object flag. The flag is
set on the module when Module#refine is called, and if the
flag is present when the module is included in another module
or class, an origin iclass is created for the module.

Fixes [Bug #13446]
2019-11-28 19:57:04 +09:00
Jeremy Evans 5069c5f521 Honor refinements for modules that prepend other modules
This previously did not work, and the reason it did not work is
that:

1) Refining a module or class that prepends other modules places
   the refinements in the class itself and not the origin iclass.

2) Inclusion of a module that prepends other modules skips the
   module itself, including only iclasses for the prepended modules
   and the origin iclass.

Those two behaviors combined meant that the method table for the
refined methods for the included module never ends up in the
method lookup chain for the class including the module.

Fix this by not skipping the module itself when the module is
included.  This requires some code rearranging in
rb_include_class_new to make sure the correct method tables and
origin settings are used for the created iclass.

As origin iclasses shouldn't be exposed to Ruby, this also
requires skipping modules that have origin iclasses in
Module#ancestors (classes that have origin iclasses were already
skipped).

Fixes [Bug #16242]
2019-11-28 19:57:04 +09:00
aycabta 4325f08086 Add require "irb" to test/irb/test_completion.rb 2019-11-28 15:32:21 +09:00
aycabta 7d75e94ea9 Fix regexp to complete complex literal
IRB completion logic always needed exponential notation for complex literal
such as 3e6i but it's bug. I fixed to support complex literal without
exponential notation such as 3i.
2019-11-28 15:22:38 +09:00
Nobuyoshi Nakada 8b4ee5d6ba
Raise `NoMatchingPatternError` when expr `in` pat doesn't match
* `expr in pattern` should raise `NoMatchingError` when unmatched
* `expr in pattern` should return `nil`. (this is unspecified, but
  this feature is experimental, at all)

[Feature #16355]
2019-11-28 13:47:14 +09:00
aycabta 2d0a1a1869 Fix ghost method line no 2019-11-28 08:19:05 +09:00
Jeremy Evans 299a13612e Don't modify rest array when using ruby2_keywords
Previously, the rest array was modified, but it turns out that is
not necessary.  Not modifying the rest array fixes cases when the
rest array is used more than once.
2019-11-27 20:03:27 +02:00
Nobuyoshi Nakada 9e01fcd0cb
[ripper] Fixed unique key check in pattern matching
Check keys
* by an internal table, instead of unstable dispatched results
* and by parsed key values, instead of escaped forms in the source
2019-11-26 22:54:35 +09:00
Nobuyoshi Nakada 26625bc33c
[ripper] Quoted label without expression must be a local variable
The difference from 0b8c73aa65 is to
add the result of `string_add` event to marking objects.

```C
			    RNODE($1)->nd_rval = add_mark_object(p, $$);
```
2019-11-25 17:42:59 +09:00
Kazuhiro NISHIYAMA 9318e1ff3e
Use realpath to try to fix failures with symlinks 2019-11-23 11:41:27 +09:00
aycabta b0614a0f96 Tracer.set_get_line_procs should support block and Proc object
Original Tracer.set_get_line_procs is implemented by
"def set_get_line_procs(p = proc)". It means that original
Tracer.set_get_line_procs supports block and Proc object.
2019-11-23 05:44:35 +09:00
aycabta 1ee010a317 Tracer.add_filter should support block and Proc object
Original Tracer.add_filter is implemented by "def add_filter(p = proc)". It
means that original Tracer.add_filter supports block and Proc object.
2019-11-23 05:43:07 +09:00
Kazuhiro NISHIYAMA d7f100226d
Skip test_validate_gemspec when tarball and git installed too
`git --version` failed as expected when git is not installed,
but unexpectedly pass when git installed and pwd is not in git working directory.
So use `git rev-parse` instead, and it failed when git installed too.
2019-11-23 01:57:19 +09:00
Jeremy Evans a9d4f2d03c Support %U/%u/%W/%w/%V/%g/%G formats in Time.strptime
Most of these formats were documented as supported, but were not
actually supported. Document that %g and %G are supported.

If %U/%W is specified without yday and mon/mday are not specified,
then Date.strptime is used to get the appropriate yday.

If cwyear is specifier without the year, or cwday and cweek are
specified without mday and mon, then use Date.strptime and convert
the resulting value to Time, since Time.make_time cannot handle
those conversions

Fixes [Bug #9836]
Fixes [Bug #14241]
2019-11-21 03:32:20 +02:00
aycabta 8f1062127e Add test/reline/test_string_processing.rb 2019-11-21 07:28:18 +09:00
aycabta 91bf3b7a77 Use singleline/multiline instead of readline/reidline 2019-11-21 02:44:35 +09:00
Nobuyoshi Nakada 9b52bacc62
Refined inspection of argument forwarding 2019-11-21 02:18:13 +09:00
manga_osyo 6723aa07e5 Change argument `Proc` to `#call` defined object.
This is the same as the behavior of Readline.
2019-11-21 00:47:37 +09:00
Kazuhiro NISHIYAMA 777973084e
Add tests of argument forwarding's parameters and inspect 2019-11-20 17:57:52 +09:00
zverok 50cc934145 Update representation (discussed on ruby tracker) 2019-11-20 13:42:56 +09:00
zverok baf482bab4 Fix test_module.rb 2019-11-20 13:42:56 +09:00
zverok 4b583cff97 Method parameters inspect
Example:

    def m(a, b=nil, *c, d:, e: nil, **rest, &block)
    end
    p method(:m)
    #=> #<Method: m(a, b=<default>, *c, d:, e: <default>, **rest, &block) ...>
2019-11-20 13:42:56 +09:00
aycabta bc0da8e3ff Generate history file path correctly when $HOME/.irbrc doesn't exist 2019-11-20 08:19:58 +09:00
Kazuki Tsujimoto ff41663403
Fix memory corruption in Enumerable#reverse_each [ruby-dev:50867] [Bug #16354] 2019-11-19 15:35:14 -06:00
Nobuyoshi Nakada 61131edba7
Revert "[ripper] Quoted label without expression must be a local variable"
This reverts commit 0b8c73aa65, which
seems breaking RVALUE consistency check.
2019-11-20 00:56:04 +09:00
Kazuki Tsujimoto 2439948bcc
Avoid needless object allocation 2019-11-19 08:53:01 -06:00
Kazuhiro NISHIYAMA 822d7ae316
Add a test
and rename from b.rb

[ruby-core:95055] [Bug #16177]
2019-11-19 17:36:47 +09:00
Nobuyoshi Nakada 0b8c73aa65
[ripper] Quoted label without expression must be a local variable 2019-11-19 17:18:27 +09:00
Nobuyoshi Nakada 473e314791 Prefer dedecated assertions 2019-11-19 02:38:56 +09:00
Takashi Kokubun 0be0d90ab0
pack is not using invokebuiltin anymore 2019-11-18 09:31:36 -08:00
Yusuke Endoh 0c0278b90a test/-ext-/string/test_fstring.rb: suppress a warning for taint 2019-11-18 09:25:49 -06:00
Koichi Sasada c3693bbaaa catch up last commit.
Array#pack uses `opt_invokebuiltin_delegate_leave` now.
2019-11-18 10:24:38 +09:00
Jeremy Evans ab42e5a486 More fixes for $SAFE/taint post merging 2019-11-18 01:00:25 +02: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
Jeremy Evans c5c05460ac Warn on access/modify of $SAFE, and remove effects of modifying $SAFE
This removes the security features added by $SAFE = 1, and warns for access
or modification of $SAFE from Ruby-level, as well as warning when calling
all public C functions related to $SAFE.

This modifies some internal functions that took a safe level argument
to no longer take the argument.

rb_require_safe now warns, rb_require_string has been added as a
version that takes a VALUE and does not warn.

One public C function that still takes a safe level argument and that
this doesn't warn for is rb_eval_cmd.  We may want to consider
adding an alternative method that does not take a safe level argument,
and warn for rb_eval_cmd.
2019-11-18 01:00:25 +02:00
Kazuhiro NISHIYAMA 449b2b9214
Fix typos 2019-11-17 13:11:25 +09:00
aycabta fa7618e4c1 Implement em_set_mark and em_exchange_mark 2019-11-15 16:50:40 +09:00
Nobuyoshi Nakada 4d615a0c8f
`#@1` is no longer an embedded variable 2019-11-14 16:37:25 +09:00
Yusuke Endoh 48edaf8b8a test/ruby/test_proc.rb: suppress "method redefined" warnings 2019-11-14 13:00:25 +09:00
Takashi Kokubun a8f9e25ca8
Suspend many fibers test on JIT for now
https://github.com/ruby/ruby/runs/301411717

No C backtrace information and this is hard to fix immediately.
As CI doesn't provide helpful information, this should be debugged
locally or at least have more logs there.
2019-11-13 09:38:22 -08:00
Takashi Kokubun 3324bc9d17
Skip tailcall test for MJIT
failing in https://github.com/ruby/ruby/runs/300579218
2019-11-12 23:10:04 -08:00
Dylan Thacker-Smith ac112f2b5d Avoid top-level search for nested constant reference from nil in defined?
Fixes [Bug #16332]

Constant access was changed to no longer allow top-level constant access
through `nil`, but `defined?` wasn't changed at the same time to stay
consistent.

Use a separate defined type to distinguish between a constant
referenced from the current lexical scope and one referenced from
another namespace.
2019-11-13 15:36:58 +09:00
aycabta a5b6d7bca8 Suppress warnings except for when last evaluation
Co-authored-by: Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
2019-11-13 15:15:28 +09:00
Takashi Kokubun 331655cbe7
Migrate Wercker MJIT tests to Actions (#2676)
* Migrate Wercker MJIT tests to Actions

* Support pull request for testing

* Capitalize other jobs too

* Make it a command name for consistency [ci skip]

* Remove wercker.yml

* Add --jit-verbose=2 for debugging

* Install MJIT headers

* Separate install for sudo

* Trigger build
2019-11-12 21:48:05 -08:00
Nobuyoshi Nakada bf34ade7ef
Show the name `Kernel#proc` in the warning message 2019-11-12 22:58:09 +09:00
manga_osyo 3816622fbe Fixed `assert_equal` first argument to be expected. 2019-11-12 21:03:22 +09:00
osyo-manga fe45bee093 Reline#readline and Reline#readmultiline to private. 2019-11-12 21:03:22 +09:00
Nobuyoshi Nakada 3bf8ffad71
Added assertions for realpath and realdirpath
It is said that realpath(3) and realdirpath(3) on some platforms
may return a relative path.
2019-11-12 18:04:20 +09:00
Nobuyoshi Nakada fb6a489af2
Revert "Method reference operator"
This reverts commit 67c5747369.
[Feature #16275]
2019-11-12 17:24:48 +09:00
Nobuyoshi Nakada a58b4eee25
Warn on `...` at EOL 2019-11-12 17:14:14 +09:00
Jeremy Evans b38b26c62d
[ruby/bigdecimal] Remove taint checking
This removes the taint checking.  Taint support is deprecated in
Ruby 2.7 and has no effect.  I don't think removing the taint
checks in earlier ruby versions will cause any problems.

https://github.com/ruby/bigdecimal/commit/1918d466f3
2019-11-12 11:16:07 +09:00
Jeremy Evans 30fdee65d9
[ruby/psych] Remove taint support
Ruby 2.7 deprecates taint and it no longer has an effect.
The lack of taint support should not cause a problem in
previous Ruby versions.

I'm not sure if the untaint calls in deduplicate are still needed
after the removal of tainting in the parser.  If they are not
needed, they should be removed.

https://github.com/ruby/psych/commit/73c1a2b4e0
2019-11-12 10:35:47 +09:00
Koichi Sasada fd6445b7e8 Monitor#exit: check monitor ownership.
Monitor#exit should be called by only onwer Thread. However, there
is not check for it.
2019-11-12 10:07:45 +09:00
Nobuyoshi Nakada ed90ec3e0d
Clear current argument name at empty block argument [Bug #16343] 2019-11-12 09:40:18 +09:00
Yusuke Endoh 9594f57f3d test/ruby/test_require.rb: Remove the tests of require with $SAFE
The taint mechanism is decided to be removed at 2.7.  [Feature #16131]
So, this change removes the tests that expects a SecurityError when
requiring a file under $SAFE >= 1.

The reason why they should be removed in advance is because the upstream
of rubygems has already removed a call to "untaint" method, which makes
the tests fail.
2019-11-12 08:31:13 +09:00
Kazuhiro NISHIYAMA 9d3213ac85
Skip test_validate_gemspec unless git installed 2019-11-11 19:03:43 +09:00
NARUSE, Yui fd69f82675 Revert "Warn EOF char in comment"
This reverts commit 69ec3f70fa.
2019-11-11 17:37:21 +09:00
NARUSE, Yui ba5b51ca59 Revert "Elaborated EOF char message a little"
This reverts commit 6eaac7cfac.
2019-11-11 17:37:14 +09:00
Hiroshi SHIBATA 7d463e360b Merge RubyGems 3.1.0.pre3
* Fix gem pristine not accounting for user installed gems. Pull request
    #2914 by Luis Sagastume.
  * Refactor keyword argument test for Ruby 2.7. Pull request #2947 by
    SHIBATA Hiroshi.
  * Fix errors at frozen Gem::Version. Pull request #2949 by Nobuyoshi
    Nakada.
  * Remove taint usage on Ruby 2.7+. Pull request #2951 by Jeremy Evans.
  * Check Manifest.txt is up to date. Pull request #2953 by David Rodríguez.
  * Clarify symlink conditionals in tests. Pull request #2962 by David
    Rodríguez.
  * Update command line parsing to work under ps. Pull request #2966 by
    David Rodríguez.
  * Properly test `Gem::Specifications.stub_for`. Pull request #2970 by
    David Rodríguez.
  * Fix Gem::LOADED_SPECS_MUTEX handling for recursive locking. Pull request
    #2985 by MSP-Greg.
2019-11-11 16:59:49 +09:00
Nobuyoshi Nakada 6eaac7cfac
Elaborated EOF char message a little 2019-11-11 12:57:40 +09:00
Nobuyoshi Nakada 390293525a
Remove binary data at installation
And revert "Relaxed warning assertions",
6f9be8505d.
2019-11-11 12:20:03 +09:00
Nobuyoshi Nakada 6f9be8505d
Relaxed warning assertions 2019-11-11 12:09:19 +09:00
Nobuyoshi Nakada 69ec3f70fa
Warn EOF char in comment 2019-11-11 09:59:40 +09:00
Nobuyoshi Nakada ade0388894
Fixed embedded document with EOF char 2019-11-11 09:38:14 +09:00
Nobuyoshi Nakada b5dff926e7
Prefer assert_syntax_error and assert_valid_syntax 2019-11-11 09:16:00 +09:00
Takashi Kokubun a733893939
Fix uplevel of test_jit 2019-11-10 14:12:13 -08:00
Takashi Kokubun fcd9bc28e3
qsymbols and symbols should be colored as Symbol 2019-11-10 13:54:44 -08:00
Takashi Kokubun 25c53a8eec
Colorize on_symbols_beg (%I) 2019-11-10 13:41:41 -08:00
Takashi Kokubun b5996b25ae
Colorize string quotes as bold
like pry
2019-11-10 13:33:23 -08:00
Kazuki Tsujimoto 6e70fa49b1
Disallow omission of parentheses/brackets in single line pattern matching [Feature #16182] 2019-11-10 22:34:49 +09:00
Takashi Kokubun 4570284ce1
Test opt_invokebuiltin_delegate_leave in test_jit 2019-11-09 21:56:38 -08:00
Takashi Kokubun 5c168c7e7f
Support RB_BUILTIN in ISeq#to_a 2019-11-09 21:40:38 -08:00
Takashi Kokubun 0483d01f6b
Test invokebuiltin in test_jit
ISeq#to_a is commented out because it's broken now
2019-11-09 21:16:16 -08:00
Takashi Kokubun e0094df29d
Extend sleep duration for Solaris 2019-11-09 13:22:51 -08:00
David Rodríguez f48655d04d Remove unneeded exec bits from some files
I noticed that some files in rubygems were executable, and I could think
of no reason why they should be.

In general, I think ruby files should never have the executable bit set
unless they include a shebang, so I run the following command over the
whole repo:

```bash
find . -name '*.rb' -type f -executable -exec bash -c 'grep -L "^#!" $1 || chmod -x $1' _ {} \;
```
2019-11-09 21:36:30 +09:00
Kazuki Tsujimoto 79f0e7aafd
Fix typos 2019-11-09 21:12:29 +09:00
John Hawthorn 3b6954f8b9 Fix passing actual object_id to finalizer
Previously we were passing the memory_id. This was broken previously if
compaction was run (which changes the memory_id) and now that object_id
is a monotonically increasing number it was always broken.

This commit fixes this by defering removal from the object_id table
until finalizers have run (for objects with finalizers) and also copying
the SEEN_OBJ_ID flag onto the zombie objects.
2019-11-08 12:41:05 -08:00
Kazuki Tsujimoto cfccd59cb1
Fix typo 2019-11-08 12:44:31 +09:00
Kazuki Tsujimoto d4da74ea78
Define Struct#deconstruct_keys 2019-11-08 11:37:46 +09:00
Koichi Sasada e2a45cb984 use builtin for TracePoint.
Define TracePoint in trace_point.rb and use __builtin_ syntax.
2019-11-08 09:09:29 +09:00
Aaron Patterson dddf5afb79
Add a counter for compaction
Keep track of the number of times the compactor ran.  I would like to
use this as a way to keep track of inline cache reference updates.
2019-11-07 12:46:14 -08:00
John Hawthorn b99833baec
Use a monotonically increasing number for object_id
This changes object_id from being based on the objects location in
memory (or a nearby memory location in the case of a conflict) to be
based on an always increasing number.

This number is a Ruby Integer which allows it to overflow the size of a
pointer without issue (very unlikely to happen in real programs
especially on 64-bit, but a nice guarantee).

This changes obj_to_id_tbl and id_to_obj_tbl to both be maps of Ruby
objects to Ruby objects (previously they were Ruby object to C integer)
which simplifies updating them after compaction as we can run them
through gc_update_table_refs.

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2019-11-07 09:31:07 -08:00
Kazuki Tsujimoto a396bef8d8
Disallow duplicated pattern variable 2019-11-07 15:40:35 +09:00
Aaron Patterson e58814d150
Revert "Use a monotonically increasing number for object_id"
This reverts commit bd2b314a05.
2019-11-06 15:12:28 -08:00
John Hawthorn bd2b314a05 Use a monotonically increasing number for object_id
This changes object_id from being based on the objects location in
memory (or a nearby memory location in the case of a conflict) to be
based on an always increasing number.

This number is a Ruby Integer which allows it to overflow the size of a
pointer without issue (very unlikely to happen in real programs
especially on 64-bit, but a nice guarantee).

This changes obj_to_id_tbl and id_to_obj_tbl to both be maps of Ruby
objects to Ruby objects (previously they were Ruby object to C integer)
which simplifies updating them after compaction as we can run them
through gc_update_table_refs.

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2019-11-06 14:59:53 -08:00
Nobuyoshi Nakada 2fd465540f
Numbered parameter is an ID_LOCAL now [Bug #16293] 2019-11-06 12:45:11 +09:00
Nobuyoshi Nakada 82e840ad15
Numbered parameter cannot appear outside block now [Bug #16293] 2019-11-06 12:44:50 +09:00
Nobuyoshi Nakada f72dc407f2
Prohibit calling undefined allocator [Bug #16297] 2019-11-06 11:17:09 +09:00
Nobuyoshi Nakada aa94245a09
Undefine MatchData.allocate [Feature #16294] 2019-11-06 08:54:32 +09:00
aycabta 6aacef4948 Assert return value of Readline.readline only if Ruby is before 2.7 2019-11-05 21:06:29 +09:00
NARUSE, Yui bea322a352 Revert "[EXPERIMENTAL] Make Symbol#to_s return a frozen String [Feature #16150]"
This reverts commit 6ffc045a81.
2019-11-05 17:30:54 +09:00
Nobuyoshi Nakada cbbdb4e5a2
[ruby/racc] Strip trailing whitespaces at the last line of actions
https://github.com/ruby/racc/commit/a887ebe529
2019-11-04 09:28:01 +09:00
Nobuyoshi Nakada 5a7487bdcd
Added assertions for linebreak 2019-11-03 23:20:01 +09:00
Kenichi Kamiya 452bee3ee8 Revert nil error and adding deprecation message 2019-11-03 11:03:04 +01:00
Jeremy Evans 469545307f [ruby/date] Add more timezone abbreviations
This gets the time zone abbreviations from
https://www.timeanddate.com/time/zones/, and adds unambiguous time
zones not already present in zonetab.list.  See bin/update-abbr
for the program used.

This regenerates zonetab.h using prereq.mk (requires gperf).

Only one test line is added, just to make sure a new time zone
abbreviation is picked up.

Fixes Ruby Bug 16286

https://github.com/ruby/date/commit/702e8b3033
2019-11-01 17:30:14 +09:00
Alan Wu 0aaa15f636 [ruby/zlib] Fix setting mtime to zero in GzipWriter
Before this change, it was not possible to write out zero for the
timestamp part of a Gzip file's header, as calling GzipWriter#mtime with
zero was ignored.

Judging from the docs for `GzipWriter#mtime=`, it should be possible to
indicate that no timestamp is available by calling the method with zero.

https://github.com/ruby/zlib/commit/310be39cac
2019-10-31 22:23:58 +09:00
Jeremy Evans ebc884461b
[ruby/stringio] Remove taint support
Ruby 2.7 deprecates taint and it no longer has an effect.
The lack of taint support should not cause a problem in
previous Ruby versions.

https://github.com/ruby/stringio/commit/60ee9ccd95
2019-10-31 16:24:02 +09:00
Jeremy Evans 3895e548bd [ruby/date] Revert "Simplify #inspect"
This reverts commit af01edd7d8575f544f647dbe8cde5b6ae535d459.

Revert requested by Yui Naruse.

https://github.com/ruby/date/commit/875d563557
2019-10-31 15:51:30 +09:00
glaszig fce940aac7 [ruby/date] introduce Date::Error, raise Date::Error for every
"invalid <anything>" type of exception

https://github.com/ruby/date/commit/3e55c09ba4
2019-10-31 15:51:25 +09:00
Jeremy Evans 290903dba0
[ruby/zlib] Remove taint support
Ruby 2.7 deprecates taint and it no longer has an effect.
The lack of taint support should not cause a problem in
previous Ruby versions.

https://github.com/ruby/zlib/commit/21711ed0ce
2019-10-31 15:34:01 +09:00
Hiroshi SHIBATA e08f2e47e3 Also ignore mswin platform 2019-10-31 08:39:48 +09:00
Hiroshi SHIBATA 8540efd342 Ignore test_racc_command with linux platform 2019-10-31 08:39:48 +09:00
Hiroshi SHIBATA 1c03026ea3 Try to run assert_output_unchanged with racc tests 2019-10-31 08:39:48 +09:00
Alan Wu 4c7f789e94 Allow only one argument for keyword_init struct
```
irb(main):001:0> RUBY_VERSION
=> "2.6.5"
irb(main):002:0> S = Struct.new(:foo, keyword_init: true)
=> S(keyword_init: true)
irb(main):003:0> S.new({foo: 23424}, 234) # I don't think this is intentional
=> #<struct S foo=23424>
irb(main):004:0>
```

Tightening this up should inform users when they are confused about
whether a struct is `keyword_init`.
2019-10-31 00:37:53 +09:00
Hiroshi SHIBATA e6d611ad37
Regenerate the output results for test fixtures of racc 2019-10-30 21:02:07 +09:00
Nobuyoshi Nakada fee5cde00b
Fix tests for CVE-2018-6914
Since the current working directory is not involved in `Tempfile`
and `Dir.mktmpdir` (except for the last resort), it is incorrect
to derive the traversal path from it.  Also, since the rubyspec
temporary directory is created under the build directory, this is
not involved in the target method.  Fixed sporadic errors in
test-spec.
2019-10-29 22:40:41 +09:00
Yusuke Endoh 7bf51ced55 test/rubygems/test_gem.rb: early failure when there is /tmp/Gemfile
Some test cases in rubygems assume that /tmp/Gemfile does not exist.
If it does, they fail with very difficult-to-understand message:

```
[ 149/2108] TestGemBundlerVersionFinder#test_bundler_version_with_bundle_update_bundler = 0.00
  1) Failure:
TestGemBundlerVersionFinder#test_bundler_version_with_bundle_update_bundler [/home/mame/work/ruby/test/rubygems/test_gem_bundler_version_finder.rb:38]:
Expected Gem::Version.new("2.0.2") to be nil.
```

I spent one hour to debug this issue.  To prevent the same accident,
this change makes the test suite stop when /tmp/Gemfile explicitly.
2019-10-29 14:40:26 +09:00
Yusuke Endoh 79a7fd9120 Revert "Revert "[ruby/rdoc] Use omit of test-unit instead of skip of minitest""
This reverts commit ca5812fe45.

Now tool/lib/minitest provides "omit", so it should work.
2019-10-29 13:16:31 +09:00
Yusuke Endoh ca5812fe45 Revert "[ruby/rdoc] Use omit of test-unit instead of skip of minitest"
This reverts commit b4da6fc1c2.

`make test-all` uses minitest, which led to "undefined method `omit'"
2019-10-29 12:57:31 +09:00
aycabta 9525541d02 [ruby/rdoc] Use Dir.glob to convert short path of Dir.tmpdir to long path
https://github.com/ruby/rdoc/commit/ba16e44572
2019-10-29 12:34:44 +09:00
aycabta c8ce37d427 [ruby/rdoc] Support different drive latters in include paths
https://github.com/ruby/rdoc/commit/946d2592e2
2019-10-29 12:34:44 +09:00
aycabta b4da6fc1c2 [ruby/rdoc] Use omit of test-unit instead of skip of minitest
https://github.com/ruby/rdoc/commit/1c5bf2ae1d
2019-10-29 12:34:44 +09:00
Nobuyoshi Nakada b4229c0a90
Restore `in_kwarg` flag properly 2019-10-29 08:58:39 +09:00
卜部昌平 cc5580f175 fix bug in keyword + protected combination
Test included for the situation formerly was not working.
2019-10-28 14:38:05 +09:00
Nobuyoshi Nakada d70fdeedf0 Make `(#methodname)` a link 2019-10-26 15:48:11 +09:00
Nobuyoshi Nakada cf9344131c Raise on end-exclusive ranges [Feature #14784]
Raises an error on end-exclusive ranges unless endless, regardless
the receiver.
2019-10-26 12:52:50 +09:00
Kazuhiro NISHIYAMA f625a4be3c [ruby/forwardable] Fix NoMethodError on ruby 2.4 or earlier
https://github.com/ruby/forwardable/runs/242918994#step:5:12
```
Error: test_obj_single_delegators_send_id(TestForwardable): NoMethodError: private method `attr_reader' called for #<Class:#<Object:0x00005605af501f58>>
```

https://github.com/ruby/forwardable/commit/711bbb2466
2019-10-26 09:25:17 +09:00
Jeremy Evans d00551a7bb [ruby/forwardable] Make def_{instance,single}_delegators skip :__send__ and :__id__
Previously, __send__ and __id__ were skipped if provided as strings,
but not skipped if provided as symbols.

Fixes Ruby Bug 8855.

https://github.com/ruby/forwardable/commit/2e61c8c66c
2019-10-26 09:25:06 +09:00
Jeremy Evans 0c579b0a97 [ruby/dbm] Remove taint support
Ruby 2.7 deprecates taint and it no longer has an effect.
The lack of taint support should not cause a problem in
previous Ruby versions.

https://github.com/ruby/dbm/commit/1f0ff0bce1
2019-10-26 07:03:33 +09:00
Nobuyoshi Nakada 42c652d195 Fixed range argument condition [Feature #14784]
Allows a beginless/endless range, and an end-exclusive range
unless the receiver is smaller than its end.
2019-10-25 23:30:47 +09:00
卜部昌平 f3f1d89d46 skip tests that do not work on GC.stress
These tests rely on GC.stat and GC.last_gc_info, which are not
stable when GC.stress is true.  Skip them for that case.
2019-10-25 16:44:15 +09:00
Jeremy Evans fb15e79403 Handle case where ruby2_keywords method splats to ruby2_keywords method
Previously, the keyword hash was duped (which results in a regular
hash), but the dup was not marked as a keyword hash, causing the
hash not to be marked as keyword hash even though it should be.
2019-10-24 17:25:43 -07:00
wanabe 4ff2c58f91 retry tailcall optimization (#2529)
Sorry, f62f90367f is push miss.
2019-10-25 04:40:39 +09:00
Jeremy Evans d6a2507e49 Duplicate hash when converting keyword hash to keywords
This mirrors the behavior when manually splatting a hash.  This
mirrors the changes made in setup_parameters_complex in
6081ddd6e6, so that splatting to a
non-iseq method works the same as splatting to an iseq method.
2019-10-24 12:35:04 -07:00
Jeremy Evans 5fe8943fda Fix typo causing Date.new(year, month) to fail
Add a test for this case.
2019-10-24 12:34:51 -07:00
Nobuyoshi Nakada b609bdeb53
Define arguments forwarding as `ruby2_keywords` style
Get rid of these redundant and useless warnings.

```
$ ruby -e 'def bar(a) a; end; def foo(...) bar(...) end; foo({})'
-e:1: warning: The last argument is used as the keyword parameter
-e:1: warning: for `foo' defined here
-e:1: warning: The keyword argument is passed as the last hash parameter
-e:1: warning: for `bar' defined here
```
2019-10-25 01:16:05 +09:00
Nobuyoshi Nakada 4b3e007e07
Assert no-kwrest case 2019-10-25 01:07:22 +09:00
Nobuyoshi Nakada ed65e2d5ae
Assert no-block case 2019-10-25 00:56:27 +09:00
Nobuyoshi Nakada 8d0c5eb805
Set method locations 2019-10-25 00:54:24 +09:00
Nobuyoshi Nakada 6279e45cde
Arguments forwarding is not allowed in lambda [Feature #16253] 2019-10-25 00:15:39 +09:00
Hiroshi SHIBATA dc44ab2913 Revert "[ruby/fiddle] Fix a failing test (#13)"
This reverts commit 5ebb0d50f6.
2019-10-24 20:58:32 +09:00
Hiroshi SHIBATA de5ee47c3d Revert "[ruby/fiddle] test: use env Hash"
This reverts commit 4d844cbaed.
2019-10-24 20:58:32 +09:00
Jeremy Evans c28d50a753 [ruby/webrick] Support literal IPv6 addresses in X-Forwarded-Host
https://github.com/ruby/webrick/commit/6b6990ec81
2019-10-24 19:47:20 +09:00
Jeremy Evans 37c266aa57 [ruby/webrick] Remove the squishing of whitespace in header values
While the stripping of header values is required by RFC 2616 4.2 and
RFC 7230 3.2.4, the squishing is not and can break things, such as
when one header contains an HMAC of another header.

Fixes Ruby Bug 7021.

https://github.com/ruby/webrick/commit/8b96088a86
2019-10-24 19:47:10 +09:00
thekuwayama f0452574b1 [ruby/webrick] after ruby-2.6.0, set Net::HTTP#write_timeout
https://github.com/ruby/webrick/commit/3b51f6b4d2
2019-10-24 19:46:01 +09:00
Jeremy Evans b809784817 [ruby/fiddle] Remove taint support (#21)
Ruby 2.7 deprecates taint and it no longer has an effect.
The lack of taint support should not cause a problem in
previous Ruby versions.
https://github.com/ruby/fiddle/commit/18d6fb6915
2019-10-24 19:34:49 +09:00
Nobuyoshi Nakada 30d46966a9 [ruby/fiddle] Use RbConfig::SIZEOF (#19)
https://github.com/ruby/fiddle/commit/ea06b28db8
2019-10-24 19:34:36 +09:00
Sutou Kouhei 4d844cbaed [ruby/fiddle] test: use env Hash
https://github.com/ruby/fiddle/commit/a01a962342
2019-10-24 19:34:29 +09:00
Kenta Murata 5ebb0d50f6 [ruby/fiddle] Fix a failing test (#13)
* Fix a failing test

This commit fixes the following failure:

```
  1) Failure:
Fiddle::TestImport#test_no_message_with_debug [/Users/mrkn/src/github.com/ruby/fiddle/test/fiddle/test_import.rb:152]:

1. [2/2] Assertion for "stderr"
   | <[]> expected but was
   | <["Exception `NameError' at /Users/mrkn/.rbenv/versions/2.5.1/lib/ruby/2.5.0/fiddle/import.rb:157 - uninitialized constant Fiddle::Function::STDCALL"]>.
```

* Stop using Bundler.with_clean_env

* Clear existing Ruby environment variables on test_no_message_with_debug

https://github.com/ruby/fiddle/commit/13133ddec8
2019-10-24 19:34:22 +09:00
zverok 913807bd6c
[ruby/date] Simplify #inspect
https://github.com/ruby/date/commit/af01edd7d8
2019-10-24 18:39:04 +09:00
Jeremy Evans 2e37c1960a
[ruby/date] Remove taint support
Ruby 2.7 deprecates taint and it no longer has an effect.
The lack of taint support should not cause a problem in
previous versions.

https://github.com/ruby/date/commit/519470dc3b
2019-10-24 18:39:04 +09:00
Jeremy Evans fc0e8d00bc
[ruby/date] Support -Float::INFINITY...date ranges
Fixes Ruby Bug 12961

https://github.com/ruby/date/commit/7f533c2552
2019-10-24 18:39:04 +09:00
Jeremy Evans 4e40ca301c
[ruby/date] Check for numeric arguments in constructors
Previously, the type of these arguments were not checked, leading to
NoMethodErrors in some cases, and TypeErrors in other cases, but not
showing what field was having the problems.  This change makes it so
the field with the problem is included in the error message.

For the valid_*? methods, this changes them to return false if one
of the arguments that should be numeric is not.

Fixes Ruby Bug 11935
Fixes Ruby Misc 15298

https://github.com/ruby/date/commit/a2f4b665f8
2019-10-24 18:39:04 +09:00
Jeremy Evans 9eb798a3f1
[ruby/date] Make julian dates roundtrip through to_time.to_date
Previously, julian dates would not round trip through to_time.to_date,
because Time is always considered gregorian.  This converts the Date
instance from julian to gregorian before converting to Time, ensuring
that an equal date object will be returned if converting that Time
back to Date.

This does result in julian Date objects showing different day values
if converting to Time.

Fixes Ruby Bug 8428.

https://github.com/ruby/date/commit/d8df64555e
2019-10-24 18:39:04 +09:00
Koichi Sasada 4c3e3b8028 Revert "Fix Fiber#transfer"
This reverts commit fa8ac91e95.

Previous behavior is intentional.
2019-10-24 16:46:21 +09:00
Nobuyoshi Nakada d5d5844744
Use dedicated assertion methods for warning and syntax error 2019-10-23 02:30:14 +09:00
MSP-Greg 22845176d7
test/ruby/test_exception typo fix 2019-10-22 14:06:45 +09:00
Jeremy Evans fa8ac91e95
Fix Fiber#transfer
Fiber#transfer previously made it impossible to resume the fiber
if it was transferred to (no resuming the target of Fiber#transfer).
However, the documentation specifies that you cannot resume a fiber
that has transferred to another fiber (no resuming the source of
Fiber#transfer), unless control is transferred back.

Fix the code by setting the transferred flag on the current/source
fiber, and unsetting the transferred flag on the target fiber.

Fixes [Bug #9664]
Fixes [Bug #12555]
2019-10-21 16:54:58 -07:00
Nobuyoshi Nakada 62d4382877 Arguments forwarding [Feature #16253] 2019-10-22 02:35:43 +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
Nobuyoshi Nakada 431132f037 Pass the called keyword arguments if `keyword_init` 2019-10-21 15:30:00 +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
MSP-Greg 9223466752 test_exception - fix with & w/o did_you_mean
See Ruby issue 16263
2019-10-21 09:11:27 +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
Nobuyoshi Nakada e2b719bed6
Support DidYouMean by AmbiguousOption too 2019-10-18 17:46:53 +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
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
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
Jeremy Evans 0162e7e647 Make circular argument reference a SyntaxError instead of a warning
Fixes [Bug #10314]
2019-10-17 09:32:06 -07:00
Nobuyoshi Nakada e169ad93f4 Fixed File.extname at a name ending with a dot
File.extname now returns a dot string at a name ending with a dot.
[Bug #15267]
2019-10-17 18:51:51 +09:00
Kenichi Kamiya 2a22a6b2d8 Regexp#match{?} with nil raises TypeError as String, Symbol (#1506)
* {String|Symbol}#match{?} with nil returns falsy

To improve consistency with Regexp#match{?}

* String#match(nil) returns `nil` instead of TypeError
* String#match?(nil) returns `false` instead of TypeError
* Symbol#match(nil) returns `nil` instead of TypeError
* Symbol#match?(nil) returns `false` instead of TypeError

* Prefer exception

* Follow empty ENV

* Drop outdated specs

* Write ruby/spec for above

https://github.com/ruby/ruby/pull/1506/files#r183242981

* Fix merge miss
2019-10-17 17:44:46 +09:00
Jeremy Evans d5744aff3a Fix DRbServer#any_to_s
My previous fix in d0ed935d5b was
not correct, as pointed out by cremno on GitHub.

This simplifies things by just using Kernel#to_s.  Also switch to
bind_call(obj) instead of bind(obj).call for better performance.
2019-10-16 12:51:13 -07:00
Jeremy Evans 567e312d1f Do not raise an exception on a closed DRb socket
This rescues some exceptions that could happen with a closed or
shutdown DRb socket. This can prevent the server from
exiting if an client socket is closed directly after it is
accepted.

Fixes [Bug #8039]
2019-10-16 12:51:13 -07:00
Jeremy Evans 2993b24a1e Warn for calling public/protected/private/module_function without arguments inside method
Calling these methods without an argument does not have the
desired effect inside a method.

Fixes [Bug #13249]
2019-10-16 12:50:40 -07:00
Takashi Kokubun 5437d7c879
Temporarily drop test_jit_debug.rb
Still some CIs are failing:
https://ci.appveyor.com/project/ruby/ruby/builds/28141041/job/v4hfc99sjefqabkk
http://ci.rvm.jp/results/trunk-vm-asserts@silicon-docker/2317313

I'll fix them later.
2019-10-16 00:11:41 -07:00
Nobuyoshi Nakada d70855c725
Added test for rdoc `--force-update` option 2019-10-16 15:16:55 +09:00
Nobuyoshi Nakada 17ee01e3f6
Removed an unused assignment 2019-10-16 15:16:54 +09:00
Takashi Kokubun c15856d76d
Do not test --jit-debug on -DVM_CHECK_MODE 2019-10-15 23:14:55 -07:00
Takashi Kokubun 4ccb49bad3
Enforce --jit-debug test by another way 2019-10-15 22:47:20 -07:00
Jeremy Evans 6081ddd6e6 Dup hash with keyword flag when converted to keywords
When ruby2_keywords is used on a method, keywords passed to the method
are flagged.  When the hash is passed as the last element of an
argument splat to another method, the hash should be treated as a
keyword splat.  When keyword splatting a hash, a duplicate of the
hash is made.  So when auto-splatting the hash with the keyword
flag, a duplicate of the hash should also be made.

This fixes cases where the hash is later passed to another method
and would be treated as keywords there:

  class Object
    ruby2_keywords def foo(*a) bar(*a) end
    def bar(*a) baz(*a) end
    def baz(*a, **kw) [a, kw] end
  end
  foo(:a=>1)

Previously, this would pass the :a=>1 as keywords to bar and also as
keywords to baz. Now it only passes :a=>1 as keywords to bar, but bar
passes :a=>1 as a positional hash to baz (which in this case
generates a warning in 2.7).
2019-10-15 12:46:24 -07:00
Nobuyoshi Nakada 929d5fd3b9 Comparable#clamp with a range [Feature #14784] 2019-10-16 01:42:34 +09:00
Yusuke Endoh 375cf12918 test/csv/write/test_general.rb: suppress warnings
of "setting Encoding.default_internal".
2019-10-15 23:29:49 +09:00
Hiroshi SHIBATA 51a31b86e9 [rubygems/rubygems] Also bump test variable
https://github.com/rubygems/rubygems/commit/97e9768612
2019-10-15 20:56:33 +09:00
Kazuhiro NISHIYAMA b7079e5384
Try to avoid random failure
https://rubyci.org/logs/rubyci.s3.amazonaws.com/openbsd-current/ruby-master/log/20191015T070011Z.fail.html.gz
```
  1) Failure:
TestProcess#test_kill_at_spawn_failure [/home/chkbuild/chkbuild/tmp/build/20191015T070011Z/ruby/test/ruby/test_process.rb:2276]:
[ruby-core:69304] [Bug #11166].
<#<Thread:0x000009f60a7cac40@/home/chkbuild/chkbuild/tmp/build/20191015T070011Z/ruby/test/ruby/test_process.rb:2272 dead>> expected but was
<nil>.
``
2019-10-15 18:53:33 +09:00
Ary Borenszweig 96617ad1d5 IRB colorize: take into account recursive arrays and hashes (#2555)
[Bug #16250]
2019-10-14 21:25:05 -07:00
Florian Frank a4cf11c10f
[flori/json] fix test as reported in #343
https://github.com/flori/json/commit/565c72ba9e
2019-10-14 19:54:49 +09:00
Nobuyoshi Nakada 2003755a2c
[flori/json] Fixed unexpected illegal/malformed utf-8 error
flori/json@c34d01ff6a does not
consider US-ASCII compatible but non-UTF-8 encodings, and causes
an error in RDoc tests.

https://github.com/flori/json/commit/4f471bf590
2019-10-14 19:54:48 +09:00
Jeremy Evans d0ed935d5b Fix some DRb issues (#2552)
* Handle BasicObject in drb

Also fix a bug in rescue clause of any_to_s because sprintf
does not handle the %l modifier.

Fixes [Bug #7833]

* Do not send a reply to the client if there is a connection error

This allows for normal TCP shutdown (fin-ack-fin-ack instead of
fin-ack-push-rst).

Patch from pierre@mouraf.org (Pierre-Alexandre Meyer).

Fixes [Bug #2339]

* Detect fork and do not reuse forked connections in drb

This associates each DRbConn with a pid, and if the pid changes,
it closes any DRbConns in the pool with a pid that no longer
matches.  This fixes DRb servers from sending messages intended
for one client to another client after forking.

Fixes [Bug #2718]
Fixes [Bug #14471]
2019-10-14 14:20:32 +09:00
Sutou Kouhei 95c420c4a6
Import StringScanner 1.0.3 (#2553) 2019-10-14 12:40:50 +09:00
Sutou Kouhei 92df7d98b6
Import CSV 3.1.2 (#2547) 2019-10-12 14:03:21 +09:00
Sutou Kouhei 412cd56766
Import REXML 3.2.3 (#2548) 2019-10-12 12:07:15 +09:00
Yusuke Endoh 9e4a53fe13 test/ruby/test_rubyoptions.rb (test_encoding): skipped on Android
On Android, nl_langinfo() always returns UTF-8 even when LANG is C.
2019-10-11 21:39:21 +09:00
Yusuke Endoh f3c4e620ac test/test_syslog.rb (test_log): skipped on Android
On Android 28, LOG_PERROR is defined, but not implemented yet.
This change skips Syslog#log explicitly.
2019-10-11 21:13:52 +09:00
Jeremy Evans 2322c94dd6 Support delegates for BasicObject
For BasicObject, bind the Kernel respond_to? instance method to the
object and call it instead of calling the method directly.

Also, use bind_call(recv, ...) for better performance.

Fixes [Bug #16127]
2019-10-10 13:15:00 -07:00
Yusuke Endoh a886d5cb79 test/ruby/test_file_exhaustive.rb: check the owner of the root directory
The root directory may be owned by the current user, for example, in
chroot environment.
2019-10-10 23:18:44 +09:00
Nobuyoshi Nakada c144d7215b
Skip very time consuming test [Bug #16196] 2019-10-10 21:02:45 +09:00
Nobuyoshi Nakada 0131fab749
Slimed down test runtime by stressing openssl.so only [Bug #16196] 2019-10-10 19:59:21 +09:00
Nobuyoshi Nakada 203b7fa1ae
Guard static variable first
* ext/openssl/ossl_asn1.c (Init_ossl_asn1): register the static
  variable to grab an internal object, before creating the object.
  otherwise the just-created object could get collected during the
  global variable list allocation.  [Bug #16196]
2019-10-10 16:25:28 +09:00
Nobuyoshi Nakada 6f522455bf [rubygems/rubygems] Do not compare with unreliable Gem::Specification::TODAY
https://gist.github.com/ko1/a88834d744a0682711dab53fd9015a04#file-brlog-trunk-nopara-20191005-235153-L393-L472

https://github.com/rubygems/rubygems/commit/707408d8e7
2019-10-10 14:51:48 +09:00
Nobuyoshi Nakada dc2b301994 [rubygems/rubygems] Restrict possible date range
https://github.com/rubygems/rubygems/commit/1bd77f53df
2019-10-10 14:51:47 +09:00
Nobuyoshi Nakada c2065c64cb
Fixed numbered parameter check
* parse.y (struct local_vars): moved numbered parameter NODEs for
  nesting check to separate per local variable scopes, as numbered
  parameters should belong to local variable scopes.  [Bug #16248]
2019-10-10 14:07:45 +09:00
Jeremy Evans 7909f06212 Check for invalid hex escapes in URI#query=
Fixes [Bug #11275]
2019-10-08 07:30:55 -07:00
卜部昌平 11b6ff12af more use of RbConfig::LIMITS
`8 * RbConfig::SIZEOF` ... is not straight.
2019-10-08 11:21:20 +09:00
Kenta Murata dd0c75fdc2
Import changes from ruby/bigdecimal (#2531)
Sync to ruby/bigdecimal@92356ba71c
2019-10-08 09:06:28 +09:00
Jeremy Evans 468184a996 Allow ruby2_keywords to be used with bmethods
There are libraries that use define_method with argument splats
where they would like to pass keywords through the method. To
more easily allow such libraries to use ruby2_keywords to handle
backwards compatibility, it is necessary for ruby2_keywords to
support bmethods.
2019-10-07 07:37:12 -07:00
Prajjwal Singh c8542ab484 Add: Array#intersection method 2019-10-07 15:59:12 +09:00
aycabta 309f6a7726 Swap expected and actual correctly 2019-10-07 14:15:05 +09:00
Koichi Sasada ddf5020e4f Revert "tailcall optimization again (#2528)"
This reverts commit f62f90367f.
2019-10-06 17:01:00 +09:00
wanabe f62f90367f tailcall optimization again (#2528)
This is follow up of r67315.
2019-10-06 16:52:09 +09:00
Yusuke Endoh 6525d3bcc7 test/dtrace/helper.rb: Etc.getgrnam may return nil on some platforms 2019-10-06 15:23:00 +09:00
Nobuyoshi Nakada 3e3cc0885a
Now keyword parameter warnings are suppressed by 871005bdd2
This reverts commits:

* 2a490d5660
  Suppress assert_match warnings.

* d4a86e407e
  Assert warnings message for the last argument is keyword parameter.
2019-10-05 11:30:05 +09:00
Nobuyoshi Nakada 6dfe0c9dcd
[rubygems/rubygems] The date might have advanced since TODAY has been set
https://bugs.ruby-lang.org/issues/16189

https://github.com/rubygems/rubygems/commit/e331222163
2019-10-05 10:50:02 +09:00
bronzdoc b659c1b92f
[rubygems/rubygems] Add Gem::Dependency#identity method
https://github.com/rubygems/rubygems/commit/05146bb2fd
2019-10-05 10:50:02 +09:00
Nobuyoshi Nakada 871005bdd2
[rubygems/rubygems] Suppress keywords warning in ruby 2.7
https://github.com/rubygems/rubygems/commit/892bfc11fe
2019-10-05 10:50:02 +09:00
Nobuyoshi Nakada 39e8d5e1cd
[rubygems/rubygems] Use dedicated assertion methods
For better messages at failures.

https://github.com/rubygems/rubygems/commit/971455b16e
2019-10-05 10:50:01 +09:00
Nobuyoshi Nakada f8104d9e9f
[rubygems/rubygems] Fixed assertion arguments
It is `assert_eqal(expected, actual)`.

https://github.com/rubygems/rubygems/commit/1d6197a090
2019-10-05 10:50:01 +09:00
Hiroshi SHIBATA ad67adb5f9
[ruby/fileutils] Use pend instead of skip
https://github.com/ruby/fileutils/commit/ba2c24e2d7
2019-10-03 18:32:29 +09:00
Jeremy Evans ef697388be
Treat return in block in class/module as LocalJumpError (#2511)
return directly in class/module is an error, so return in
proc in class/module should also be an error.  I believe the
previous behavior was an unintentional oversight during the
addition of top-level return in 2.4.
2019-10-02 07:56:28 -07:00
Alan Wu 99d3043bd8 Iseq#to_binary: dump flag for **nil (#2508)
RUBY_ISEQ_DUMP_DEBUG=to_binary and the attached test case was failing.
Dump the flag to make sure `**nil` can round-trip properly.
2019-10-02 16:05:40 +09:00
Yusuke Endoh 3ce238b5f9 WEBrick: prevent response splitting and header injection
This is a follow up to d9d4a28f1c.
The commit prevented CRLR, but did not address an isolated CR or an
isolated LF.

Co-Authored-By: NARUSE, Yui <naruse@airemix.jp>
2019-10-01 19:19:56 +09:00
Nobuyoshi Nakada 36e057e26e Loop with String#scan without creating substrings
Create the substrings necessary parts only, instead of cutting the
rest of the buffer.  Also removed a useless, probable typo, regexp.
2019-10-01 19:19:56 +09:00
Nobuyoshi Nakada a0a2640b39 Fix for wrong fnmatch patttern
* dir.c (file_s_fnmatch): ensure that pattern does not contain a
  NUL character.  https://hackerone.com/reports/449617
2019-10-01 19:19:56 +09:00
Koichi Sasada 671ca21254 remove `unused var` warning 2019-10-01 01:14:19 +09:00
Jeremy Evans 3073404e74 Add rb_enumeratorize_with_size_kw and related macros
Currently, there is not a way to create a sized enumerator in C
with a different set of arguments than provided by Ruby, and
correctly handle keyword arguments.  This function allows that.

The need for this is fairly uncommon, but it occurs at least in
Enumerator.produce, which takes arugments from Ruby but calls
rb_enumeratorize_with_size with a different set of arguments.
2019-09-30 07:06:42 -07:00
Yusuke Endoh 5ddc2ba13e test/ruby/test_io.rb: supress a "method redefined" warning
by explicitly removing the old definition.
2019-09-30 20:24:26 +09:00
Yusuke Endoh fc66947c61 test/-ext-/string/test_fstring.rb: suppress "possibly useless use of -@"
"in void context" by assigning the result to a dummy variable.
2019-09-30 20:22:29 +09:00
Nobuyoshi Nakada 771fd915a4
Use assert_operator instead of mere assert 2019-09-30 17:39:38 +09:00
Nobuyoshi Nakada 1722c156dd
Now `use_symbol` is always true 2019-09-30 17:38:54 +09:00
Koichi Sasada 88f38c187e Emulate method_list (chkbuild) on test-all.
chkbuild (CI process) shows methods list before
running tests and sometimes it can fails. This
commit a code part to emulate this method listing
feature.
2019-09-30 15:36:19 +09:00
Jeremy Evans 649a64ae29 Add three more C-API functions for handling keywords
This adds rb_funcall_passing_block_kw, rb_funcallv_public_kw,
and rb_yield_splat_kw.  This functions are necessary to easily
handle cases where rb_funcall_passing_block, rb_funcallv_public,
and rb_yield_splat are currently used and a keyword argument
separation warning is raised.
2019-09-29 18:31:08 -07:00
Nobuyoshi Nakada 59648af296
Suppress keyword argument warning from #step
* numeric.c (num_step): pass the extracted argument from keyword
  argument, not the last argument itself which should have been
  warned already.
2019-09-30 01:17:55 +09:00
Jeremy Evans d53cf85474 Fix warning when doing Struct.new(:x, keyword_init: true){}
This is due to calling rb_mod_module_eval directly instead of using
rb_funcall_passing_block.

The problem with calling directly is it does not create a new VM
frame, so rb_mod_module_eval was called with no arguments, but with
the keyword given VM frame flag set, which causes problems
internally.
2019-09-27 11:22:21 -07:00
Jeremy Evans 7814b6c657 Correctly issue ArgumentError when calling method that accepts no keywords
If a method accepts no keywords and was called with a keyword, an
ArgumentError was not always issued previously.  Force methods that
accept no keywords to go through setup_parameters_complex so that
an ArgumentError is raised if keywords are provided.
2019-09-27 11:21:50 -07:00
Jeremy Evans a2c26fe1c6 Fix fallback in URI.encode_www_form_component to include #
Patch from Matthew Kerwin.

Fixes [Bug #14358]
2019-09-27 07:43:32 -07:00
Jeremy Evans 43a16c98df Do not escape + in Shellwords.escape
+ is not a character that requires escaping in Bourne sh.

Fixes [Bug #14429]
2019-09-27 07:43:32 -07:00
Jeremy Evans 2b6a9f3a1f Ignore Errno::EPIPE when sending requests in net/http
An EPIPE when sending the request should be ignored.  Even if you
cannot write more data, you may still be able to read the server's
response.

Fixes [Bug #14466]
2019-09-27 07:43:32 -07:00
Nobuyoshi Nakada 79d5332a2d
Drop eliminated catch-entries
Drop catch table entries used in eliminated block, as well as
call_infos.  [Bug #16184]
2019-09-27 21:12:27 +09:00
Nobuyoshi Nakada 4d3502d57f
More tests for [Feature #16150] 2019-09-27 14:01:37 +09:00
Jeremy Evans 9792c9d183
[ruby/fileutils] Fix test_cp_r_dev on Windows or other systems without character/block device in /dev
Previously this would give an error such as:

TestFileUtils#test_cp_r_dev [c:/fileutils/test/fileutils/test_fileutils.rb:455]:
[RuntimeError] exception expected, not.
Class: <TypeError>
Message: <"no implicit conversion of nil into String">

https://github.com/ruby/fileutils/commit/0ce0fefbeb
2019-09-27 11:39:02 +09:00
Jeremy Evans 9494ef8b2d
[ruby/fileutils] Do not break in verbose mode if using FileUtils with a frozen object
If FileUtils is included into another object, and verbose mode is
used, a FrozenError is currently raised unless the object has the
@fileutils_output and @fileutils_label instance variables.

This fixes things so that it does not attempt to set the instance
variables, but it still uses them if they are present.

https://github.com/ruby/fileutils/commit/689cb9c56a
2019-09-27 11:39:02 +09:00
Jeremy Evans 02cd420505
[ruby/fileutils] Skip test_cp_r_socket on JRuby
https://github.com/ruby/fileutils/commit/20bb9ec789
2019-09-27 11:39:02 +09:00
Jeremy Evans 1d99163aa5
[ruby/fileutils] Make copy methods handle FIFOs and UNIX sockets
Previously, this was broken.  Trying to copy a FIFO would raise a
NoMethodError if File.mkfifo was defined.  Trying to copy a UNIX
socket would raise a RuntimeError as File.mknod is not something
Ruby defines.

Handle the FIFO issue using File.mkfifo instead of mkfifo.

Handle the UNIX Socket issue by creating a unix socket.

Continue to not support character or block devices, raising a
RuntimeError for both.

Add tests for FIFO, UNIX Socket, and character/block devices.

https://github.com/ruby/fileutils/commit/123903532d
2019-09-27 11:39:02 +09:00
Jeremy Evans 660c7e050f Fix more keyword separation issues
This fixes instance_exec and similar methods. It also fixes
Enumerator::Yielder#yield, rb_yield_block, and a couple of cases
with Proc#{<<,>>}.

This support requires the addition of rb_yield_values_kw, similar to
rb_yield_values2, for passing the keyword flag.

Unlike earlier attempts at this, this does not modify the rb_block_call_func
type or add a separate function type.  The functions of type
rb_block_call_func are called by Ruby with a separate VM frame, and we can
get the keyword flag information from the VM frame flags, so it doesn't need
to be passed as a function argument.

These changes require the following VM functions accept a keyword flag:

* vm_yield_with_cref
* vm_yield
* vm_yield_with_block
2019-09-26 19:24:58 -07:00
Aaron Patterson 293c6c8cc3
Add compaction support to `rb_ast_t`
This commit adds compaction support to `rb_ast_t`.
2019-09-26 15:41:46 -07:00
Jeremy Evans 37f9213f89 Fix keyword argument separation issues in Enumerator::Generator#each
This requires adding rb_proc_call_kw to pass the keyword flag.
2019-09-26 15:30:51 -07:00
George Claghorn 31339ef4f2 Honor Syslog::Logger#level overrides 2019-09-26 15:01:44 -07:00
Nobuyoshi Nakada 81191afe8a
Kernel#open may be redefined 2019-09-27 01:13:10 +09:00
Jeremy Evans b193041b99 Fix keyword argument separation issues in Fiber#resume 2019-09-26 08:01:53 -07:00
Jeremy Evans 6b52959ef7 Fix keyword argument separation issues in Thread.new 2019-09-26 08:01:53 -07:00
Jeremy Evans 47d44510a3 Fix more keyword argument separation issues in Pathname 2019-09-26 08:01:53 -07:00
Jeremy Evans 3959469f24 Fix keyword argument separation issues in OpenSSL::SSL::SSLSocket#sys{read,write}_nonblock
It's unlikely anyone would actually hit these.  The methods are
private, you only hit this code path if calling these methods
before performing the SSL connection, and there is already a
verbose warning issued.
2019-09-26 08:01:53 -07:00
Jeremy Evans 760893d2f8 Fix keyword argument separation issues in Proc#{<<,>>}
This requires adding rb_proc_call_with_block_kw.
2019-09-26 08:01:53 -07:00
Jeremy Evans 0aa267f985 Fix keyword argument sepration issues when IO#open calls #to_open 2019-09-26 08:01:53 -07:00
Jean Boussier 5b9d646944 Fix Module#name news and add a test 2019-09-26 23:29:49 +09:00
Nobuyoshi Nakada b29c68e687
Restore ENV, rubygems always sets SOURCE_DATE_EPOCH now 2019-09-26 22:57:25 +09:00
Hiroshi SHIBATA 2a490d5660
Suppress assert_match warnings. 2019-09-26 18:24:20 +09:00
Hiroshi SHIBATA d4a86e407e
Assert warnings message for the last argument is keyword parameter. 2019-09-26 18:07:17 +09:00
David Rodríguez a2af473018
[rubygems/rubygems] Make sure our modifications to kernel.warn work
And test the fix we're adding.

https://github.com/rubygems/rubygems/commit/6f86637b98
2019-09-26 17:48:01 +09:00
Hiroshi SHIBATA 966915d807
[rubygems/rubygems] indent
https://github.com/rubygems/rubygems/commit/8cdb2fd66f
2019-09-26 17:48:01 +09:00
bronzdoc 0b65a7a19e
[rubygems/rubygems] Fix test_gem_attr
https://github.com/rubygems/rubygems/commit/7c5b66f9ef
2019-09-26 17:48:01 +09:00
f 73633683c5
[rubygems/rubygems] add tests
https://github.com/rubygems/rubygems/commit/8a7e27381c
2019-09-26 17:48:01 +09:00
David Rodríguez ea5b136155
[rubygems/rubygems] Fix underscore version for bundler itself
Previously it wouldn't play nice with the bundler version finder.

https://github.com/rubygems/rubygems/commit/d8bb81556d
2019-09-26 17:48:01 +09:00
bronzdoc d1c97ceb86
[rubygems/rubygems] Update expectation in test_to_ruby_with_rsa_key
https://github.com/rubygems/rubygems/commit/2e65f7d4ae
2019-09-26 17:48:01 +09:00
bronzdoc 8f2379b0c5
[rubygems/rubygems] Make ruby_code method handle OpenSSL::PKey::RSA objects
https://github.com/rubygems/rubygems/commit/b1d825ab3a
2019-09-26 17:48:00 +09:00
Ellen Marie Dash 508afe2c26
[rubygems/rubygems] Set SOURCE_DATE_EPOCH env var if not provided.
Fixes #2290.

1. `Gem::Specification.date` returns SOURCE_DATE_EPOCH when defined,
2. this commit makes RubyGems set it _persistently_ when not provided.

This combination means that you can build a gem, check the build time,
and use that value to generate a new build -- and then verify they're
the same.

https://github.com/rubygems/rubygems/commit/d830d53f59
2019-09-26 17:48:00 +09:00
Daniel Berger 8436b2717c
[rubygems/rubygems] Add a gem attr to the Gem::Package class.
https://github.com/rubygems/rubygems/commit/5b81f364ae
2019-09-26 17:48:00 +09:00
Benoit Daloze 6ffc045a81 [EXPERIMENTAL] Make Symbol#to_s return a frozen String
* Always the same frozen String for a given Symbol.
* Avoids extra allocations whenever calling Symbol#to_s.
* See [Feature #16150]
2019-09-26 10:23:02 +02:00
Takashi Kokubun 5d8f112505
RubyVM::MJIT.pause(wait: true) should wait
for all compilations and compaction.

Prior to this commit, the last-compiled code has not been used because
MJIT worker is stopped before setting the code, and compaction has also
been skipped.

But it was not intentional and `wait: true` pause should wait until
those two things by its feature.
2019-09-26 16:28:34 +09:00
Alan Wu 93faa011d3 Tag string shared roots to fix use-after-free
The buffer deduplication codepath in rb_fstring can be used to free the buffer
of shared string roots, which leads to use-after-free.

Introudce a new flag to tag strings that at one point have been a shared root.
Check for it in rb_fstring to avoid freeing buffers that are shared by
multiple strings. This change is based on nobu's idea in [ruby-core:94838].

The included test case test for the sequence of calls to internal functions
that lead to this bug. See attached ticket for Ruby level repros.

[Bug #16151]
2019-09-26 15:30:18 +09:00
Nobuyoshi Nakada 3cee99808d [EXPERIMENTAL] Expression with modifier `in`
[Feature #15865]
2019-09-26 15:10:48 +09:00
Jeremy Evans 3b302ea8c9 Add Module#ruby2_keywords for passing keywords through regular argument splats
This approach uses a flag bit on the final hash object in the regular splat,
as opposed to a previous approach that used a VM frame flag.  The hash flag
approach is less invasive, and handles some cases that the VM frame flag
approach does not, such as saving the argument splat array and splatting it
later:

  ruby2_keywords def foo(*args)
    @args = args
    bar
  end
  def bar
    baz(*@args)
  end
  def baz(*args, **kw)
    [args, kw]
  end
  foo(a:1)    #=> [[], {a: 1}]
  foo({a: 1}, **{}) #=> [[{a: 1}], {}]

  foo({a: 1}) #=> 2.7: [[], {a: 1}] # and warning
  foo({a: 1}) #=> 3.0: [[{a: 1}], {}]

It doesn't handle some cases that the VM frame flag handles, such as when
the final hash object is replaced using Hash#merge, but those cases are
probably less common and are unlikely to properly support keyword
argument separation.

Use ruby2_keywords to handle argument delegation in the delegate library.
2019-09-25 12:33:52 -07:00
Jeremy Evans 80b5a0ff2a
Make rb_scan_args handle keywords more similar to Ruby methods (#2460)
Cfuncs that use rb_scan_args with the : entry suffer similar keyword
argument separation issues that Ruby methods suffer if the cfuncs
accept optional or variable arguments.

This makes the following changes to : handling.

* Treats as **kw, prompting keyword argument separation warnings
  if called with a positional hash.

* Do not look for an option hash if empty keywords are provided.
  For backwards compatibility, treat an empty keyword splat as a empty
  mandatory positional hash argument, but emit a a warning, as this
  behavior will be removed in Ruby 3.  The argument number check
  needs to be moved lower so it can correctly handle an empty
  positional argument being added.

* If the last argument is nil and it is necessary to treat it as an option
  hash in order to make sure all arguments are processed, continue to
  treat the last argument as the option hash. Emit a warning in this case,
  as this behavior will be removed in Ruby 3.

* If splitting the keyword hash into two hashes, issue a warning, as we
  will not be splitting hashes in Ruby 3.

* If the keyword argument is required to fill a mandatory positional
  argument, continue to do so, but emit a warning as this behavior will
  be going away in Ruby 3.

* If keyword arguments are provided and the last argument is not a hash,
  that indicates something wrong. This can happen if a cfunc is calling
  rb_scan_args multiple times, and providing arguments that were not
  passed to it from Ruby.  Callers need to switch to the new
  rb_scan_args_kw function, which allows passing of whether keywords
  were provided.

This commit fixes all warnings caused by the changes above.

It switches some function calls to *_kw versions with appropriate
kw_splat flags. If delegating arguments, RB_PASS_CALLED_KEYWORDS
is used.  If creating new arguments, RB_PASS_KEYWORDS is used if
the last argument is a hash to be treated as keywords.

In open_key_args in io.c, use rb_scan_args_kw.
In this case, the arguments provided come from another C
function, not Ruby.  The last argument may or may not be a hash,
so we can't set keyword argument mode.  However, if it is a
hash, we don't want to warn when treating it as keywords.

In Ruby files, make sure to appropriately use keyword splats
or literal keywords when calling Cfuncs that now issue keyword
argument separation warnings through rb_scan_args.  Also, make
sure not to pass nil in place of an option hash.

Work around Kernel#warn warnings due to problems in the Rubygems
override of the method.  There is an open pull request to fix
these issues in Rubygems, but part of the Rubygems tests for
their override fail on ruby-head due to rb_scan_args not
recognizing empty keyword splats, which this commit fixes.

Implementation wise, adding rb_scan_args_kw is kind of a pain,
because rb_scan_args takes a variable number of arguments.
In order to not duplicate all the code, the function internals need
to be split into two functions taking a va_list, and to avoid passing
in a ton of arguments, a single struct argument is used to handle
the variables previously local to the function.
2019-09-25 11:18:49 -07:00
Nobuyoshi Nakada 33c5ad3154
Removed idNUMPARAM_0 2019-09-25 13:52:53 +09:00
Nobuyoshi Nakada 55e1e22b2d
Changed numbered parameters semantics
* `_1` (and no other numbered parameters) to work as `|x|`.
* giving up `_0`.

[ruby-core:95074] [Bug #16178]
2019-09-25 13:01:03 +09:00
Kazuhiro NISHIYAMA c99fb0f41e
Revert "[ruby/io-console] Skip cursor position test on Solaris"
This reverts commit 5294ded681.
2019-09-25 09:48:44 +09:00
Nobuyoshi Nakada c60451d9cd [ruby/io-console] Unique paths to be added
https://github.com/ruby/io-console/commit/a3ad851b6c
2019-09-25 09:43:31 +09:00
Nobuyoshi Nakada fc9eb5b9c1 [ruby/io-console] Load the current libraries
https://github.com/ruby/io-console/commit/ab7653c543
2019-09-25 09:43:29 +09:00
Nobuyoshi Nakada 5294ded681 [ruby/io-console] Skip cursor position test on Solaris
It results in a mysterious failure.

https://github.com/ruby/io-console/commit/e3543c3da4
2019-09-25 08:24:19 +09:00
Nobuyoshi Nakada 0e84eecc17 Make numbered parameters exclusive in a scope 2019-09-24 21:57:54 +09:00
Nobuyoshi Nakada ea68bb914a Changed numbered parameter prefix 2019-09-24 21:57:54 +09:00
Nobuyoshi Nakada 10e3267c31 [ruby/io-console] Made cursor position 0-origin
https://github.com/ruby/io-console/commit/9377e37295
2019-09-24 16:20:31 +09:00