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

12637 Коммитов

Автор SHA1 Сообщение Дата
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
Jeremy Evans 74e33662fe Make public_send and rb_f_send handle keyword argument separation
Kernel#send takes a different optimized code path that was already
handled.
2019-09-23 09:28:27 -07:00
Yusuke Endoh b4c328bebc test/bigdecimal/test_bigdecimal.rb: Use BigDecimal()
instead of deprecated BigDecimal.new.
2019-09-22 11:55:00 +09:00
Jeremy Evans 2e551356a7 Make Kernel#{Pathname,BigDecimal,Complex} return argument if given correct type
This is how Kernel#{Array,String,Float,Integer,Hash,Rational} work.
BigDecimal and Complex instances are always frozen, so this should
not cause backwards compatibility issues for those.  Pathname
instances are not frozen, so potentially this could cause backwards
compatibility issues by not returning a new object.

Based on a patch from Joshua Ballanco, some minor changes by me.

Fixes [Bug #7522]
2019-09-21 16:10:37 -07:00
Jeremy Evans 7470f96565 Fix Module#class_variables for singleton classes of classes/modules
Module#class_variables should reflect class variable lookup. For
singleton classes of classes/modules, this means the lookup should
be:

* Singleton Class
* Class
* All Ancestors of Class

Note that this doesn't include modules included in the singleton
class, because class variable lookup doesn't include those.

Singleton classes of other objects do not have this behavior and
always just search all ancestors of the singleton class, so do not
change the behavior for them.

Fixes [Bug #8297]
2019-09-21 16:10:18 -07:00
Yusuke Endoh 5cb283217b test/ruby/test_assignment.rb: use bug number for assert message
to suppress variable unused warning
2019-09-21 19:23:47 +09:00
Jeremy Evans c9f2b790ad Handle keyword argument separation for Enumerator#size
When Object#to_enum is passed a block, the block is called to get
a size with the arguments given to to_enum.  This calls the block
with the same keyword flag as to_enum is called with.

This requires adding rb_check_funcall_kw and
rb_check_funcall_default_kw to handle keyword flags.
2019-09-20 07:45:18 -07:00
Jeremy Evans 27b6746872 Make passing empty keywords to dig pass empty keywords to next dig method
If defined in Ruby, dig would be defined as def dig(arg, *rest) end,
it would not use keywords.  If the last dig argument was an empty
hash, it could be treated as keyword arguments by the next dig
method.  Allow dig to pass along the empty keyword flag if called
with an empty keyword, to suppress the previous behavior and force
treating the hash as a positional argument and not keywords.

Also handle the case where dig calls method_missing, passing the
empty keyword flag to that as well.

This requires adding rb_check_funcall_with_hook_kw functions, so
that dig can specify how arguments are treated.  It also adds
kw_splat arguments to a couple static functions.
2019-09-20 07:45:11 -07:00
Nobuyoshi Nakada e81a3e6df5
Allows calling a private method only with bare `self` 2019-09-20 22:05:54 +09:00
Hiroshi SHIBATA 37c0839425
Removed Synchronizer from the ruby repository. 2019-09-20 14:06:22 +09:00
Hiroshi SHIBATA 3b56a0934f
Removed Shell from the ruby repository. 2019-09-20 12:56:18 +09:00
Hiroshi SHIBATA 67a6662032
Removed Scanf from the ruby repository. 2019-09-20 12:43:11 +09:00
Hiroshi SHIBATA a3b8501614
Removed CMath from the ruby repository. 2019-09-20 12:31:37 +09:00
Nobuyoshi Nakada e6378cdcd8
Allow calling a private accessor with `self.`
[Feature #11297] [Feature #16123]
2019-09-20 02:21:37 +09:00
Dylan Thacker-Smith 7fbd2f7cc2
Allow calling a private method with `self.`
This makes it consistent with calling private attribute assignment
methods, which currently is allowed (e.g. `self.value =`).

Calling a private method in this way can be useful when trying to
assign the return value to a local variable with the same name.

[Feature #11297] [Feature #16123]
2019-09-20 02:20:59 +09:00
NARUSE, Yui 5208c431be Separate Time#inspect from to_s and show subsec [Feature #15958] 2019-09-19 20:20:15 +09:00
Nobuyoshi Nakada 2698f13a1f
Fixed reserved numbered parameter warning 2019-09-19 19:40:44 +09:00
Nobuyoshi Nakada a98181eb11
DEBUG: cxxanyargs 2019-09-19 10:46:52 +09:00
Nobuyoshi Nakada 70fd022a2a
DEBUG 2019-09-19 09:47:11 +09:00
Jeremy Evans 5177dd8ba0 Add and fix some keyword tests
Replace [arg=1, args] with [arg, args] so we can actually test
the value correctly.

Add some missing tests for **h3 when method accepts (**args).

Add tests for passing positional hashes to (**args) methods and
check for the expected warnings/errors.
2019-09-18 11:16:00 -07:00
Jeremy Evans 775365cbd2 Fix keyword argument separation issues with sym procs when using refinements
Make sure that vm_yield_with_cfunc can correctly set the empty keyword
flag by passing 2 as the kw_splat value when calling it in
vm_invoke_ifunc_block.  Make sure calling.kw_splat is set to 1 and not
128 in vm_sendish, so we can safely check for different kw_splat values.

vm_args.c needs to call add_empty_keyword, and to make JIT happy, the
function needs to be exported.  Rename the function to
rb_adjust_argv_kw_splat to more accurately reflect what it does, and
mark it as MJIT exported.
2019-09-17 16:22:44 -07:00
Jeremy Evans 9b35dc3864 Pass keyword argument flag when rb_call_super_kw calls method_missing
This makes method_missing take a flag for whether keyword arguments
were passed.

Adds tests both for rb_call_super_kw usage as well as general usage
of super calling method_missing in Ruby methods.
2019-09-17 16:22:44 -07:00
Nobuyoshi Nakada 3a3f48fb8f
Comment lines can be placed between fluent dot now 2019-09-15 23:12:24 +09:00
Jeremy Evans 24b1b33975 Correctly handle keywords for Method#call for cfuncs, send, and attr_*
This sets the correct VM frame flags when using Method#call to
call funcs, and handles empty keyword hashes for cfuncs,
attr_reader, and attr_writer. It also fixes calls to send through
Method#call.  It adds tests for all of those, as well as tests for
using Method#call to call define_method, lambda, and sym_procs
(which didn't require code changes).
2019-09-13 09:53:54 -07:00
Nobuyoshi Nakada 7e0f56fb3d
Name dynamically defined methods with line numbers 2019-09-13 19:48:44 +09:00
Akinori MUSHA ac3e8834e0
Document and test Enumerator.produce
Co-authored-by: Victor Shepelev <zverok.offline@gmail.com>
2019-09-12 20:18:53 +09:00
Jeremy Evans ed96c9f270 Emit missing keyword argument separation warnings for define_method
Previously, the warning functions skipped warning in these cases.
This removes the skipping, and uses a less descriptive warning
instead.

This affected both last argument to keyword warnings and keyword
split warnings.
2019-09-11 11:20:16 -07:00
Masaki Matsushita f5024de002 Remove check of ai.protocol
Solaris 10 returns addrinfo.ai_protocol as 0, not 6.
2019-09-10 12:39:49 +09:00
Masaki Matsushita 0e9d56f5e7 Support timeout for Addrinfo
Addrinfo.getaddrinfo and .foreach now accepts :timeout in seconds as
a keyword argument. If getaddrinfo_a(3) is available, the timeout will be
applied for name resolution. Otherwise, it will be ignored.

Socket.tcp accepts :resolv_timeout to use this feature.

This commit is retry of 6382f5cc91.
Test was failed on Solaris machines which don't have "http" in
/etc/services. In this commit, use "ssh" instead.
2019-09-10 10:10:59 +09:00
Masaki Matsushita c4efbf663e Revert "Support timeout for Addrinfo"
This reverts commit 6382f5cc91.
test failed on Solaris.
2019-09-09 20:34:51 +09:00
Yusuke Endoh cce6cfbe48 Make test-all and test-spec runnable on Android
Calling some syscall functions such as Dir.chroot causes SIGSYS instead
of EPERM on Android.
This change skips all tests that stops the test-suite run.
2019-09-09 20:24:03 +09:00
Masaki Matsushita 8c09de38c5 Fix expected ip_port 2019-09-09 18:44:42 +09:00
Masaki Matsushita 0fb2457d79 Fix service name for test
change service name to fix failed test on Solaris
2019-09-09 18:35:19 +09:00
Masaki Matsushita 461663f52a Fix domain name for test 2019-09-09 15:05:38 +09:00
Jeremy Evans 61d90da25c Fix invalid keyword argument separation warning for delegating calls
This removes an invalid keyword argument separation warning for
code such as:

```ruby
def foo(arg)
  arg
end
kw = {}
foo(*[1], **kw)
```

This warning was caused because the remove_empty_keyword_hash
was set based on a comparison with two variables, and in this
case, one of the variables was updated after the check and we
need to use the updated variable.

Simplify things by just inlining the comparison.
2019-09-08 22:47:06 -07:00
Masaki Matsushita 6382f5cc91 Support timeout for Addrinfo
Addrinfo.getaddrinfo and .foreach now accepts :timeout in seconds as
a keyword argument. If getaddrinfo_a(3) is available, the timeout will be
applied for name resolution. Otherwise, it will be ignored.

Socket.tcp accepts :resolv_timeout to use this feature.
2019-09-09 14:34:05 +09:00
Jeremy Evans fa79219356 Add keyword argument separation tests for implicit/explicit super calls
No code changes are necessary, but we didn't have as extensive
tests for these calls previously.
2019-09-08 10:34:34 -07:00
Yusuke Endoh 1e008105bc compile.c (compile_list): emit newarraykwsplat only at the last chunk
`[{}, {}, {}, ..., {}, *{}]` is wrongly created.

A big array literal is created and concatenated for every 256 elements.
The newarraykwsplat must be emitted only at the last chunk.
2019-09-07 16:05:15 +09:00
Yusuke Endoh 99c9431ea1 Rename NODE_ARRAY to NODE_LIST to reflect its actual use cases
and NODE_ZARRAY to NODE_ZLIST.

NODE_ARRAY is used not only by an Array literal, but also the contents
of Hash literals, method call arguments, dynamic string literals, etc.
In addition, the structure of NODE_ARRAY is a linked list, not an array.

This is very confusing, so I believe `NODE_LIST` is a better name.
2019-09-07 13:56:29 +09:00
Jeremy Evans 146677a1e7 Fix keyword argument warnings in the tests from Class#new
This were previously hidden because calls from C were not warned.
2019-09-06 19:41:23 -07:00
Jeremy Evans 37a2c660aa Convert keyword argument to required positional hash argument for Class#new, Method#call, UnboundMethod#bind_call
Also add keyword argument separation warnings for Class#new and Method#call.

To allow for keyword argument to required positional hash converstion in
cfuncs, add a vm frame flag indicating the cfunc was called with an empty
keyword hash (which was removed before calling the cfunc).  The cfunc can
check this frame flag and add back an empty hash if it is passing its
arguments to another Ruby method.  Add rb_empty_keyword_given_p function
for checking if called with an empty keyword hash, and
rb_add_empty_keyword for adding back an empty hash to argv.

All of this empty keyword argument support is only for 2.7.  It will be
removed in 3.0 as Ruby 3 will not convert empty keyword arguments to
required positional hash arguments.  Comment all of the relevent code
to make it obvious this is expected to be removed.

Add rb_funcallv_kw as an public C-API function, just like rb_funcallv
but with a keyword flag.  This is used by rb_obj_call_init (internals
of Class#new).  This also required expected call_type enum with
CALL_FCALL_KW, similar to the recent addition of CALL_PUBLIC_KW.

Add rb_vm_call_kw as a internal function, used by call_method_data
(internals of Method#call and UnboundMethod#bind_call). Add tests
for UnboundMethod#bind_call keyword handling.
2019-09-06 19:41:23 -07:00
Takashi Kokubun 3b60e5e6bc
Try shrinking tested VM stack max 2019-09-06 10:34:33 +09:00
Jeremy Evans 729de9ee68 Convert empty keyword hash to required positional argument and warn for method_missing
This is the same as the bmethod, sym proc, and send cases,
where we don't remove the keyword splat, so later code can
move it to a required positional parameter and warn.
2019-09-05 17:47:12 -07:00
Jeremy Evans e220b467ef Convert empty keyword hash to required positional argument and warn for sym procs
This is the same as the bmethod and send cases, where we don't
remove the keyword splat, so later code can move it to to a
a required positional parameter and warn.
2019-09-05 17:47:12 -07:00
Jeremy Evans e2878a96f7 Convert empty keyword hash to required positional argument and warn for lambda and bmethod
The lambda case is similar to the attr_writer case, except we have
to determine the number of required parameters from the iseq
instead of being able to assume a single required parameter.

This fixes a lot of lambda tests which were switched to require
warnings for all usage of keyword arguments.  Similar to method
handling, we do not warn when passing keyword arguments to
lambdas that do not accept keyword arguments, the argument is
just passed as a positional hash in that case, unless it is empty.
If it is empty and not the final required parameter, then we
ignore it.  If it is empty and the final required parameter, then
we pass it for backwards compatibility and emit a warning, as in
Ruby 3 we will not pass it.

The bmethod case is similar to the send case, in that we do not
want to remove empty keyword splats in vm_call_bmethod, as that
prevents later call handling from moving them to required
positional arguments and warning.
2019-09-05 17:47:12 -07:00
Jeremy Evans e7274a8ec4 Convert empty keyword hash to required positional argument and warn
In general, we want to ignore empty keyword hashes.  The only case
where we want to allow them for backwards compatibility is when
they are necessary to satify the final required positional argument.
In that case, we want to not ignore them, but we do want to warn,
as that will be going away in Ruby 3.

This commit implements this support for regular methods and
attr_writer methods.

In order to allow send to forward arguments correctly, send no
longer removes empty keyword hashes.  It is the responsibility of
the final method to remove the empty keyword hashes now.  This
change was necessary as otherwise send could remove the empty
keyword hashes before the regular or attr_writer methods could
move them to required positional arguments.

For completeness, add tests for keyword handling regular
methods calls.

This makes rb_warn_keyword_to_last_hash non-static in vm_args.c
so it can be reused in vm_insnhelper.c, and also moves declarations
before statements in the rb_warn_* functions in vm_args.c.
2019-09-05 17:47:12 -07:00
Jeremy Evans d1ef73b59c Always remove empty keyword hashes when calling methods
While doing so is not backwards compatible with Ruby 2.6, it is
necessary for generic argument forwarding to work for all methods:

```ruby
def foo(*args, **kw, &block)
  bar(*args, **kw, &block)
end
```

If you do not remove empty keyword hashes, and bar does not accept
keyword arguments, then a call to foo without keyword arguments
calls bar with an extra positional empty hash argument.
2019-09-05 17:47:12 -07:00
Yusuke Endoh 55b96c5d2d Add a keyword-to-last-hash warning for some case of define_method method
and lambda.

When define_method is a simple iseq (`define_method(:m) {|x| ... }`),
passing keywords to it (`m(**kw)`) didn't print a warning.
2019-09-05 17:47:12 -07:00
Yusuke Endoh dd83f7bf98 define_method should not drop the empty keyword hash
Similar to 38e9c1bc35d5549575fbb263afff560e97db068e
2019-09-05 17:47:12 -07:00
Yusuke Endoh 70f2780892 vm_call_bmethod should not drop the empty keyword hash
Similar to 38e9c1bc35d5549575fbb263afff560e97db068e
2019-09-05 17:47:12 -07:00
Yusuke Endoh 252e299009 vm_call_opt_send should not drop the empty keyword hash
Now the mechanism that conveys kw_splat flag is gradually established,
so the hack to drop the empty keyword hash is not needed for
vm_call_opt_send.
2019-09-05 17:47:12 -07:00
Yusuke Endoh 4615886c76 test_method_missing_kwsplat should call the target directly
not via Object#send which uses a fast path vm_call_opt_send.
2019-09-05 17:47:12 -07:00
Yusuke Endoh 0bfe3bf4d1 Ignore an empty keyword splat for attr_reader/writer methods 2019-09-05 17:47:12 -07:00
Yusuke Endoh 437ff40879 C method should accept a keyword hash (for compatibility with 2.6) 2019-09-05 17:47:12 -07:00
Yusuke Endoh c5555e2eb8 CALLER_SETUP_ARG removes an empty keyword hash from argv
...only when a "remove_empty_keyword_hash" flag is specified.

After CALLER_SETUP_ARG is called, `ci->flag & VM_CALL_KW_SPLAT` must not
be used.  Instead. use `calling->kw_splat`.  This is because
CALLER_SETUP_ARG may modify argv and update `calling->kw_splat`, and
`ci->flag & VM_CALL_KW_SPLAT` may be inconsistent with the result.
2019-09-05 17:47:12 -07:00
Jeremy Evans 1fffd33189 Fix passing keywords without splats to sym procs, define_method, and method_missing 2019-09-05 17:47:12 -07:00
Jeremy Evans 6f9b86616a Make Symbol#to_proc calls handle keyword arguments
Make rb_sym_proc_call take a flag for whether a keyword argument
is used, and use the new rb_funcall_with_block_kw function to
pass that information.
2019-09-05 17:47:12 -07:00
Yusuke Endoh ce04392d8d Propagate kw_splat information
The kw_splat flag is whether the original call passes keyword or not.
Some types of methods (e.g., bmethod and sym_proc) drops the
information.  This change tries to propagate the flag to the final
callee, as far as I can.
2019-09-05 17:47:12 -07:00
Jeremy Evans c6464c44c0 Fix code locations of array node inside hash node when multiple kw splats
This is broken at least since 2.5 (I didn't check earlier versions).
It resulted in failure in test_ast.rb when the tests were added before
the parser change.

Basically, in remove_duplicate_keys, if the node is modified, set
the location information to the previous location information. The
removal of keys should not affect the location in the code.
2019-09-05 09:57:43 -07:00
Jeremy Evans 1d5066efb0 Make m(**{}) mean call without keywords
Previously, **{} was removed by the parser:

```
$ ruby --dump=parse -e '{**{}}'
 @ NODE_SCOPE (line: 1, location: (1,0)-(1,6))
 +- nd_tbl: (empty)
 +- nd_args:
 |   (null node)
 +- nd_body:
     @ NODE_HASH (line: 1, location: (1,0)-(1,6))*
     +- nd_brace: 1 (hash literal)
     +- nd_head:
         (null node)
```

Since it was removed by the parser, the compiler did not know
about it, and `m(**{})` was therefore treated as `m()`.

This modifies the parser to not remove the `**{}`.  A simple
approach for this is fairly simple by just removing a few
lines from the parser, but that would cause two hash
allocations every time it was used.  The approach taken here
modifies both the parser and the compiler, and results in `**{}`
not allocating any hashes in the usual case.

The basic idea is we use a literal node in the parser containing
a frozen empty hash literal.  In the compiler, we recognize when
that is used, and if it is the only keyword present, we just
push it onto the VM stack (no creation of a new hash or merging
of keywords).  If it is the first keyword present, we push a
new empty hash onto the VM stack, so that later keywords can
merge into it.  If it is not the first keyword present, we can
ignore it, since the there is no reason to merge an empty hash
into the existing hash.

Example instructions for `m(**{})`

Before (note ARGS_SIMPLE):

```
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,7)> (catch: FALSE)
0000 putself                                                          (   1)[Li]
0001 opt_send_without_block       <callinfo!mid:m, argc:0, FCALL|ARGS_SIMPLE>, <callcache>
0004 leave
```

After (note putobject and KW_SPLAT):

```
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,7)> (catch: FALSE)
0000 putself                                                          (   1)[Li]
0001 putobject                    {}
0003 opt_send_without_block       <callinfo!mid:m, argc:1, FCALL|KW_SPLAT>, <callcache>
0006 leave
```

Example instructions for `m(**h, **{})`

Before and After (no change):

```
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE)
0000 putself                                                          (   1)[Li]
0001 putspecialobject             1
0003 newhash                      0
0005 putself
0006 opt_send_without_block       <callinfo!mid:h, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache>
0009 opt_send_without_block       <callinfo!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE>, <callcache>
0012 opt_send_without_block       <callinfo!mid:m, argc:1, FCALL|KW_SPLAT>, <callcache>
0015 leave
```

Example instructions for `m(**{}, **h)`

Before:

```
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE)
0000 putself                                                          (   1)[Li]
0001 putspecialobject             1
0003 newhash                      0
0005 putself
0006 opt_send_without_block       <callinfo!mid:h, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache>
0009 opt_send_without_block       <callinfo!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE>, <callcache>
0012 opt_send_without_block       <callinfo!mid:m, argc:1, FCALL|KW_SPLAT>, <callcache>
0015 leave
```

After (basically the same except for the addition of swap):

```
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE)
0000 putself                                                          (   1)[Li]
0001 newhash                      0
0003 putspecialobject             1
0005 swap
0006 putself
0007 opt_send_without_block       <callinfo!mid:h, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache>
0010 opt_send_without_block       <callinfo!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE>, <callcache>
0013 opt_send_without_block       <callinfo!mid:m, argc:1, FCALL|KW_SPLAT>, <callcache>
0016 leave
```
2019-09-05 09:57:43 -07:00
David Rodríguez 1c4af1a77f
Add tests for `File.absolute_path?`
[Feature #15868]
2019-09-05 20:04:50 +09:00
David Rodríguez d9e6315177
[rubygems/rubygems] Bump rubocop to 0.74.0 and fix new offenses
https://github.com/rubygems/rubygems/commit/d4fc383497
2019-09-05 18:48:15 +09:00
bronzdoc 565828a778 [rubygems/rubygems] Fix Layout/SpaceAroundOperators: Operator = should be surrounded by a single space.
https://github.com/rubygems/rubygems/commit/eaa38ebeb1
2019-09-05 18:43:45 +09:00
bronzdoc b11cfed4c4 [rubygems/rubygems] Error out if there are multiple gemspecs and no gemspec is specified
https://github.com/rubygems/rubygems/commit/547947bbf0
2019-09-05 18:43:21 +09:00
bronzdoc 400d693863 [rubygems/rubygems] Remove useless gem setup
https://github.com/rubygems/rubygems/commit/c8913e37a7
2019-09-05 18:43:12 +09:00
bronzdoc 6cacbf542c [rubygems/rubygems] Test building a gem with multiple gemspec without a gem name specified
https://github.com/rubygems/rubygems/commit/38c72fd145
2019-09-05 18:43:04 +09:00
bronzdoc a02da1012b [rubygems/rubygems] Build the first gemspec we found if no gemspec is specified
https://github.com/rubygems/rubygems/commit/ab186266b7
2019-09-05 18:42:56 +09:00
bronzdoc bcf51dd763 [rubygems/rubygems] Improve gemspec assignment and error message
https://github.com/rubygems/rubygems/commit/dc70c5a192
2019-09-05 18:42:49 +09:00
David Rodríguez fea91d69a3 [rubygems/rubygems] Don't fail when `uninstall --all` with default gem
Instead, display an informative message saying that uninstallation of
specific versions is being skipped because of being default gems.

https://github.com/rubygems/rubygems/commit/b44845aa1d
2019-09-05 18:42:26 +09:00
David Rodríguez f9f6a3d793 [rubygems/rubygems] Little refactor to avoid rubocop's false positive
Otherwise it detects duplicate methods here, because it doesn't see that
we are reopening the class in two different places.

https://github.com/rubygems/rubygems/commit/ae3fb47f5f
2019-09-05 18:42:18 +09:00
Akinori MUSHA 1d4bd229b8
Implement Enumerator::Lazy#eager [Feature #15901] 2019-09-04 16:16:46 +09:00
Takashi Kokubun c14b67b2a8
Check frozen flag on MJIT setinstancevariable
It does not seem to have a significant performance impact, hopefully?

```
$ benchmark-driver -v benchmark.yml --rbenv 'before --jit;after --jit' --repeat-count=24 --output=all
before --jit: ruby 2.7.0dev (2019-09-03T21:02:24Z master 77596fb7a9) +JIT [x86_64-linux]
after --jit: ruby 2.7.0dev (2019-09-04T01:54:44Z master 7363e22d79) +JIT [x86_64-linux]
Calculating -------------------------------------
                                 before --jit           after --jit
Optcarrot Lan_Master.nes    48.44054595799523     71.67010255902900 fps
                            71.32797692837639     71.97846863769546
                            72.51921961607691     78.87360980544105
                            73.54082925611047     79.80408132389941
                            74.03503843709451     79.85739528572826
                            74.04863857926493     79.89850834901381
                            75.30266276129467     80.34607233076015
                            75.69063990896244     80.88474397425360
                            75.70458132587405     81.09234267781642
                            77.39842764662852     82.13766823612643
                            77.76922944068329     82.20398304840373
                            81.17984044023393     82.26722630628272
                            82.85235776076533     82.71375902781254
                            83.04906099135320     82.75893420702198
                            83.10214168136230     82.79668965325972
                            83.71456007558125     82.85131667916379
                            84.06658306760725     82.95676565411722
                            84.25690684305728     83.19972846225775
                            84.27938663923503     83.28510503845854
                            84.45467716218090     83.41003730434703
                            84.51563186125925     83.67773614721280
                            84.56139892968321     84.02082201151110
                            84.69819452180658     84.10495346787033
                            84.78125989622576     84.47867803506055
```

Note for backporter:
test_jit's `success_count` would be 1 in Ruby 2.6, since 2.7 introduced
"MJIT recompile" on JIT-ed code cancel.

[Bug #16139]
2019-09-04 11:10:21 +09:00
Jeremy Evans 77596fb7a9
Do not turn on keyword_init for Struct subclass if keyword hash is empty
This was accidentally turned on because there was no checking for
Qundef.

Also, since only a single keyword is currently supported, simplify
the rb_get_kwargs call.
2019-09-03 14:02:24 -07:00
Jeremy Evans a7d7a0df91 Fix Enumerator::Lazy#{to_enum,enum_for} where method is defined in Lazy
Previously, passing to_enum/enum_for a method that was defined in
Lazy itself returned wrong results:

  [1,2,3].to_enum(:map).to_a
  # => [1, 2, 3]
  [1,2,3].lazy.to_enum(:map).to_a
  # => []

I'm not sure why methods that are designed to be lazy do not work
with to_enum/enum_for.  However, one possible way to work around
this bug is to have to_enum/enum_for use the implementation found
in Enumerable/Enumerator, which is what this commit does.

While this commit works around the problem, it is a band-aid, not a
real fix.  It doesn't handle aliases of Enumerable::Lazy methods,
for instance.  A better fix would be appreciated.
2019-09-03 11:30:49 -07:00
Jeremy Evans e94ac03eb0 Make Enumerator::Lazy#with_index be lazy
Previously, Enumerator::Lazy#with_index was not defined, so it
picked up the default implementation from Enumerator, which was
not lazy.

Based on earlier patch from nobu.

Fixes [Bug #7877]
2019-09-03 11:30:49 -07:00
Takashi Kokubun ecc37ee67b
Stop testing inexistent instructions 2019-09-03 21:38:32 +09:00
Takashi Kokubun afe8bf2489
Try extending timeout of IO.select
hoping to stabilize:
https://app.wercker.com/ruby/ruby/runs/mjit-test1/5d6df8a8a952c20008acf75b?step=5d6df90e4971a6000714c627
2019-09-03 20:34:52 +09:00
Naohisa Goto 83889292f5 Examine TestIO#test_select_exceptfds on Solaris with 1 byte data
On Solaris, it seems that the select(3C) in this test works only
when sending 1 byte out-of-band data, though I cannot investigate
the cause. The behavior is observed on a Solaris 10 server in
addition to Solaris 11 on which the test had been skipped.
2019-09-03 16:51:01 +09:00
Yusuke Endoh 547887138f test/ruby/test_fiber.rb: reduce the count of object creation to cause GC
The test consistently fails on OpenBSD.

https://rubyci.org/logs/rubyci.s3.amazonaws.com/openbsd-current/ruby-master/log/20190903T010009Z.fail.html.gz
```
  1) Failure:
TestFiber#test_fork_from_fiber [/home/chkbuild/chkbuild/tmp/build/20190903T010009Z/ruby/test/ruby/test_fiber.rb:327]:
[ruby-core:41456].
<0> expected but was
<1>.
```
2019-09-03 12:29:36 +09:00
Jeremy Evans 1994adf938 Make Array#uniq return subclass instance if called on subclass instance
Previously, Array#uniq would return subclass instance if the
length of the array were 2 or greater, and would return Array
instance if the length of the array were 0 or 1.

Fixes [Bug #7768]
2019-09-02 13:42:31 -07:00
Takashi Kokubun 1a5a01e9ce
Add insn tests for newarraykwsplat 2019-09-03 01:39:00 +09:00
Takashi Kokubun 91aa8bfff8
Drop unstable Travis osx in favor of GitHub Actions
For some reason, the Travis osx environment has been really unstable.
It failed on today's cron too:
https://travis-ci.org/ruby/ruby/builds/579843163

As we have almost the same test environment (including OpenSSL version)
in GitHub Actions and it seems to be more stable and faster, I think
there's no motivation to maintain Travis osx CI environment.

By removing this, we'd be able to simplify .travis.yml as well.
2019-09-03 01:01:48 +09:00
Jeremy Evans f560609d66
Merge pull request #2418 from jeremyevans/array-empty-kwsplat
Ignore empty keyword splats in arrays
2019-09-02 08:21:30 -07:00
Yusuke Endoh 53a7abe2cd test/drb/drbtest.rb: Skip test_06_timeout on Solaris10s
The test seems to have a race condition, which fails on very slow
machine like Solaris10s.  So skip it.

In addition, this change restores timeout guard that was removed at
0660d7cb53.  This is because the test gets
stuck forever when something wrong occurs.  It is better to fail the
test than stuck.
2019-09-02 22:33:27 +09:00
Nobuyoshi Nakada 8b2e1ca10e
Do not clear backtrace in Exception#exception
[Bug #15558]
2019-09-02 16:47:12 +09:00
Nobuyoshi Nakada 8e38d4c78c
Rewrote using assert_separately 2019-09-02 16:46:28 +09:00
Nobuyoshi Nakada 6f206b8ec6
Prohibit nul-separated glob pattern [Feature #14643] (#2419) 2019-09-02 15:08:53 +09:00
Shugo Maeda 633ae3278e
Add Net::FTP#features and Net::FTP#option
Patch by darkphnx (Dan Wentworth) .  Thanks!
[Feature #15964]
2019-09-02 14:43:51 +09:00
Jeremy Evans 6724b1f83d Revert "Make Enumerator::Lazy#with_index be lazy"
This reverts commit 83498854eb.

This didn't pass rubyspec.
2019-09-01 22:35:38 -07:00
Takashi Kokubun c69545ae32
Fix opt_regexpmatch1 references 2019-09-02 14:33:37 +09:00
Jeremy Evans 83498854eb Make Enumerator::Lazy#with_index be lazy
Previously, Enumerator::Lazy#with_index was not defined, so it
picked up the default implementation from Enumerator, which was
not lazy.

Based on earlier patch from nobu.

Fixes [Bug #7877]
2019-09-01 22:20:05 -07:00
Kazuhiro NISHIYAMA 63ab7046a1
Skip POINTOPOINT of IPv4 too instead of IPv6 only
Fix following error on `utun*`:
```
  1) Error:
TestSocket#test_udp_server:
Errno::ECONNREFUSED: Connection refused - recvmsg(2)
```
2019-09-02 12:01:47 +09:00
Jeremy Evans ca11a7d74e Fix method name in test to not override existing method name 2019-09-01 18:54:30 -07:00
Jeremy Evans 3fde9ef937 Fix keyword argument separation warning in method_missing
vm_call_method_missing was dropping VM_CALL_KW_SPLAT, so this just
makes it not drop it, to get the same behavior as calling the method
directly.
2019-09-01 16:08:42 -07:00
Yusuke Endoh 007d6d15f4 test/drb/drbtest.rb: Use EnvUtil.timeout for timeout scale factor 2019-09-01 23:29:39 +09:00
Yusuke Endoh 188c2b67c9 Revert "Revert "Revert "Skip BUGs on Solaris"""
This reverts commit 3be3948870.

The Solaris environment couldn't lookup the hostname itself by a wrong
setting.  Now it is fixed, so try again.
2019-09-01 23:27:44 +09:00
Yusuke Endoh 3be3948870 Revert "Revert "Skip BUGs on Solaris""
This reverts commit 84dca8eff0.

"exceution expired" occurred on Solaris.
https://rubyci.org/logs/rubyci.s3.amazonaws.com/solaris11s-sunc/ruby-master/log/20190901T072504Z.fail.html.gz
2019-09-01 18:57:40 +09:00
Kazuki Tsujimoto 94d6ec1d90
Make pattern matching support **nil syntax 2019-09-01 16:39:34 +09:00
Takashi Kokubun cda5745c1b
Automatically detect missing symbols
which are usually optimized away by -O3.

This CI can detect missing exports like
ea84a68075 which was needed for
761346a960.
2019-09-01 16:31:15 +09:00
Yusuke Endoh 02dfa0f163 test/ruby/test_keyword.rb: Add remove_method before method redefinition
to suppress redefinition warnings.
2019-09-01 15:24:37 +09:00
Yusuke Endoh 84dca8eff0 Revert "Skip BUGs on Solaris"
This reverts commit 8adefd4cf2.

I couldn't see any failure on Solaris if the guard is removed.
Give it a try.
2019-09-01 15:16:19 +09:00
Jeremy Evans d646a292cd Fix keyword argument separation warning when using send
vm_call_opt_send was dropping VM_CALL_KW_SPLAT, so this just makes
it not drop it, to get the same behavior as calling the method
directly.
2019-08-31 23:06:49 -07:00
Jeremy Evans 15757390ff Don't pass an empty keyword hash when double splatting empty hash when calling cfunc
This mirrors earlier changes in keyword argument separation for
calling Ruby methods and calling procs/lambdas, so that behavior
is kept the same.
2019-08-31 21:54:06 -07:00