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

13139 Коммитов

Автор SHA1 Сообщение Дата
Jeremy Evans beae6cbf0f Fully separate positional arguments and keyword arguments
This removes the warnings added in 2.7, and changes the behavior
so that a final positional hash is not treated as keywords or
vice-versa.

To handle the arg_setup_block splat case correctly with keyword
arguments, we need to check if we are taking a keyword hash.
That case didn't have a test, but it affects real-world code,
so add a test for it.

This removes rb_empty_keyword_given_p() and related code, as
that is not needed in Ruby 3.  The empty keyword case is the
same as the no keyword case in Ruby 3.

This changes rb_scan_args to implement keyword argument
separation for C functions when the : character is used.
For backwards compatibility, it returns a duped hash.
This is a bad idea for performance, but not duping the hash
breaks at least Enumerator::ArithmeticSequence#inspect.

Instead of having RB_PASS_CALLED_KEYWORDS be a number,
simplify the code by just making it be rb_keyword_given_p().
2020-01-02 18:40:45 -08:00
Nobuyoshi Nakada 34bc15c86b
Check Module#ruby2_keywords arity
It is considered a mistake, because calling this method with no
arguments has no effect.
2020-01-02 10:41:24 +09:00
aycabta 049292e302 Add load path and require for ruby/ruby 2020-01-01 02:04:41 +09:00
aycabta 66e6055c11 [ruby/irb] Fix lib name of OpenStruct
https://github.com/ruby/irb/commit/1f3a84ab6b
2020-01-01 01:38:37 +09:00
aycabta 9deb942715 Add "require 'openstruct'" what is forgotten 2019-12-31 23:32:24 +09:00
Ben a118bb805f [ruby/irb] Add tests for RubyLex
The set_auto_indent method calculates the correct number of spaces for
indenting a line. We think there might be a few bugs in this method so
we are testing the current functionality to make sure nothing breaks
when we address those bugs.

Example test failure:

```
  1) Failure:
TestIRB::TestRubyLex#test_auto_indent [/Users/Ben/Projects/irb/test/irb/test_ruby_lex.rb:75]:
Calculated the wrong number of spaces for:
 def each_top_level_statement
  initialize_input
  catch(:TERM_INPUT) do
    loop do
      begin
        prompt
        unless l = lex
          throw :TERM_INPUT if @line == ''
        else
.
<10> expected but was
<12>.
```

https://github.com/ruby/irb/commit/752d5597ab
2019-12-31 23:32:24 +09:00
Nobuyoshi Nakada 0cf75e3850 Split test_nomethod_error.rb 2019-12-31 19:43:36 +09:00
Nobuyoshi Nakada a580a3757b Split test_name_error.rb 2019-12-31 19:43:36 +09:00
Nobuyoshi Nakada ee4ead8098 Split test_frozen_error.rb 2019-12-31 19:43:36 +09:00
Nobuyoshi Nakada 8caeef7c1d Fix the exception to be raised
`NoMethodError` has been raised instead of `FrozenError`.
2019-12-31 19:43:36 +09:00
MSP-Greg d912393e09 text/readline/test_readline.rb - fix skip on Reline (#2743)
TestRelineAsReadline#test_input_metachar passes on MinGW
2019-12-31 00:29:58 -08:00
MSP-Greg eb2b425821 MinGW on Actions (#2791)
* MinGW - skip spec in spec/ruby/optional/capi/thread_spec.rb

C-API Thread function rb_thread_call_without_gvl
      -- runs a C function with the global lock unlocked and unlocks IO with the generic RUBY_UBF_IO

stops/freezes spec tests

See https://bugs.ruby-lang.org/issues/16265

* MinGW - skip test test/resolv/test_dns.rb

Test times out in CI (both AppVeyor & Actions), cannot repo locally

* MinGW - skip test test/ruby/test_thread_queue.rb

* Add Actions mingw.yml
2019-12-30 23:19:31 -08:00
Alan Wu 99c7b0b7ea
Decide lambdaness of (f << g) using g (#2729)
* Deciding lambdaness of (f << g) using g

* Use version guards for spec changes
2019-12-30 17:47:58 -05:00
Nobuyoshi Nakada 31e2f03512 [ruby/io-console] Enable only interrupt bits on `intr: true`
https://github.com/ruby/io-console/commit/baaf929041
2019-12-29 16:26:22 +09:00
aycabta 4db898284d Add test_completion_with_indent_and_completer_quote_characters
This is for 8a705245e5.
2019-12-27 16:07:52 +09:00
Nobuyoshi Nakada b25e27277d
Transform hash keys by a hash [Feature #16274] 2019-12-26 15:50:34 +09:00
Yusuke Endoh 81e377023c range.c: Range#min with a beginless one now raise an explicit exception
[Bug #16450]
2019-12-25 13:36:23 +09:00
aycabta 622e47a1db ^D on non-empty line in vi mode behaves like Enter 2019-12-25 09:34:13 +09:00
Nobuyoshi Nakada a3c5dbf291
Scale sleeping times to wait for the OS operations 2019-12-24 18:53:14 +09:00
aycabta 42e2a322f1 The delete-char-or-list shows completed list when called at end of line
It doesn't behave the same as the delete-char.
2019-12-24 18:34:43 +09:00
Nobuyoshi Nakada 81504e83e7
Synchronize with a Queue instead of sleeping 2019-12-24 15:48:08 +09:00
Koichi Sasada 47ad57f245 Revert "Scale sleeping times"
This reverts commit e57d619421.

Test fails:
http://ci.rvm.jp/results/trunk-gc-asserts@ruby-sky1/2518563
http://ci.rvm.jp/results/trunk-gc_compact@silicon-docker/2518533
2019-12-24 15:38:46 +09:00
Nobuyoshi Nakada e57d619421
Scale sleeping times 2019-12-24 14:56:17 +09:00
Nobuyoshi Nakada e954be14d0
Get rid of false positive misspellings
[Bug #16437]
2019-12-24 10:33:32 +09:00
aycabta adc9b3ca7f [ruby/rdoc] Support newline in the middle of constant definition
https://github.com/ruby/rdoc/commit/74d3984324
2019-12-24 07:58:53 +09:00
aycabta e50e552693 [ruby/rdoc] Treat Proc#call syntax sugar for constant correctly
https://github.com/ruby/rdoc/commit/957d041ae0
2019-12-24 07:58:53 +09:00
Marc-Andre Lafortune 819b604037 Reword keyword arguments warning messages to convey these are deprecation warnings 2019-12-23 16:47:33 -05:00
Koichi Sasada a96f8cecc2 ObjectSpace._id2ref should check liveness.
objspace->id_to_obj_tbl can contain died objects because of lazy
sweep, so that it should check liveness.
2019-12-23 15:04:56 +09:00
Yuki Nishijima 672a61b97f Port dd1dd86e6c 2019-12-23 00:47:41 -05:00
NAKAMURA Usaku 204dc3f39f Revert "Should return "." for File.extname("file.") also on Windows"
We want to introduce consistency and better compatibility with unixen,
but the Windows APIs doues not have consistency fundamentally and
we can not found any logical way...

This reverts commit 61aff0cd18.
2019-12-23 11:54:25 +09:00
Koichi Sasada cf59e1476d fix a thread test.
* Use Queue for synchronization.
* Don't use `sleep 0.2` and use `th.join` because created thread
  can raise an exception after 0.2 seconds.
2019-12-22 06:29:52 +09:00
Yusuke Endoh 75acbd5f00 compile.c: avoid newarraykwsplat for arguments
`foo(*rest, post, **empty_kw)` is compiled like
`foo(*rest + [post, **empty_kw])`, and `**empty_kw` is removed by
"newarraykwsplat" instruction.
However, the method call still has a flag of KW_SPLAT, so "post" is
considered as a keyword hash, which caused a segfault.
Note that the flag cannot be removed if "empty_kw" is not always empty.

This change fixes the issue by compiling arguments with "newarray"
instead of "newarraykwsplat".

[Bug #16442]
2019-12-22 03:35:29 +09:00
NAKAMURA Usaku 61aff0cd18 Should return "." for File.extname("file.") also on Windows
But not changes another cases, such as "file.rb."
[Bug #15267]
2019-12-22 02:42:09 +09:00
Alan Wu 85a337f986 Kernel#lambda: return forwarded block as non-lambda proc
Before this commit, Kernel#lambda can't tell the difference between a
directly passed literal block and one passed with an ampersand.

A block passed with an ampersand is semantically speaking already a
non-lambda proc. When Kernel#lambda receives a non-lambda proc, it
should simply return it.

Implementation wise, when the VM calls a method with a literal block, it
places the code for the block on the calling control frame and passes a
pointer (block handler) to the callee. Before this commit, the VM
forwards block arguments by simply forwarding the block handler, which
leaves the slot for block code unused when a control frame forwards its
block argument. I use the vacant space to indicate that a frame has
forwarded its block argument and inspect that in Kernel#lambda to detect
forwarded blocks.

This is a very ad-hoc solution and relies *heavily* on the way block
passing works in the VM. However, it's the most self-contained solution
I have.

[Bug #15620]
2019-12-21 09:08:52 -05:00
Yusuke Endoh ea405ee8ed test/ruby/test_pattern_matching.rb: suppress "unused variable" warning 2019-12-21 10:06:14 +09:00
Nobuyoshi Nakada 484c1be895
Added `-W:experimental` command line option
[Feature #16420]
2019-12-20 23:51:17 +09:00
Nobuyoshi Nakada 07e595fdbd
Added `experimental` warning category
[Feature #16420]
2019-12-20 23:48:15 +09:00
Nobuyoshi Nakada a84ad24386
Added -W: command line option
To manage `Warning[category]` flags.  Only `-W:deprecated` and
`-W:no-deprecated` are available now.  [Feature #16345]
2019-12-20 23:05:22 +09:00
Yusuke Endoh f7aee58498 vm_args.c: rephrase the warning message of keyword argument separation
(old)
test.rb:4: warning: The last argument is used as the keyword parameter
test.rb:1: warning: for `foo' defined here; maybe ** should be added to the call?

(new)
test.rb:4: warning: The last argument is used as keyword parameters; maybe ** should be added to the call
test.rb:1: warning: The called method `foo' is defined here
2019-12-20 19:41:15 +09:00
Nobuyoshi Nakada 2b2030f265
Refined the warning message for $, and $;
[Bug #16438]
2019-12-20 15:09:23 +09:00
Nobuyoshi Nakada 7a94225e7d
Refined the warning message for numbered-parameter like variables
[Bug #16438]
2019-12-20 14:58:51 +09:00
Nobuyoshi Nakada a8bddb3a18
Refined the warning message for numbered-parameter like variables
[Bug #16438]
2019-12-20 14:34:32 +09:00
Nobuyoshi Nakada 435a4ca2a3
Makes the receiver to FrozenError.new a keyword parameter
[Feature #16419]
2019-12-20 14:18:20 +09:00
Nobuyoshi Nakada e68999c82c
Fixed misspellings
Fixed misspellings reported at [Bug #16437], for default gems.
2019-12-20 12:19:45 +09:00
Hiroshi SHIBATA e672494cd7
Merge RubyGems 3.1.2 2019-12-20 11:50:32 +09:00
Nobuyoshi Nakada db16629008
Fixed misspellings
Fixed misspellings reported at [Bug #16437], only in ruby and rubyspec.
2019-12-20 09:32:42 +09:00
Nobuyoshi Nakada 2898367b3a
Warn also numbered parameter like methods 2019-12-20 08:18:19 +09:00
Nobuyoshi Nakada 27ddb6e998
Warn also numbered parameter like parameters
[Feature #16433]
2019-12-20 01:25:34 +09:00
Nobuyoshi Nakada 7aa8a78674
Manage deprecation warnings about keyword argument 2019-12-19 09:52:17 +09:00
Nobuyoshi Nakada 9bf9de3d9d
Made the warning for deprecated constants follow the category flag 2019-12-19 09:52:16 +09:00
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