1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
Commit graph

65731 commits

Author SHA1 Message Date
Koichi Sasada
ecfa8dcdba fix return from orphan Proc in lambda
A "return" statement in a Proc in a lambda like:
  `lambda{ proc{ return }.call }`
should return outer lambda block. However, the inner Proc can become
orphan Proc from the lambda block. This "return" escape outer-scope
like method, but this behavior was decieded as a bug.
[Bug ]

This patch raises LocalJumpError by checking the proc is orphan or
not from lambda blocks before escaping by "return".

Most of tests are written by Jeremy Evans
https://github.com/ruby/ruby/pull/4223
2021-04-02 09:25:33 +09:00
Kenichi Kamiya
c080bb2284 [Doc] Update to FrozenError from RuntimeError in Object#freeze 2021-04-01 10:10:02 -07:00
Koichi Sasada
1ac68bba4e [ruby/irb] SIGINT should raise Interrupt after IRB session
https://github.com/ruby/irb/commit/5832cfe75b
2021-04-02 01:57:44 +09:00
git
8e636bd0de * 2021-04-02 [ci skip] 2021-04-02 01:48:13 +09:00
Nobuyoshi Nakada
ccb0b7ab7d [ruby/irb] Suppress verbose messages in the parallel test
`:VERBOSE` flag needs to be set prior to `IRB::Irb.new`.

https://github.com/ruby/irb/commit/78604682d9
2021-04-02 01:47:58 +09:00
Nobuyoshi Nakada
9513fcd5bc
Suppress a warning
Loop variables of `list_for_each` need to be initialized.
2021-04-01 22:54:42 +09:00
David CARLIER
68a8f611e0 coroutine: Darwin on ARM64 needs alignment of 2^2 2021-04-01 23:51:06 +13:00
git
e675a7899c * 2021-04-01 [ci skip] 2021-04-01 12:00:35 +09:00
Nobuyoshi Nakada
a5567350f7
Refactored sub-seconds normalizations
* separated argument to `timespec2timew` from `timespec` to seconds and
  nano-seconds.

* unified nano-seconds and micro-seconds normalizations.
2021-04-01 12:00:10 +09:00
Nobuyoshi Nakada
2a02b61fae
Use EnvUtil.under_gc_stress 2021-03-31 22:14:15 +09:00
Koichi Sasada
1fac99afda skip marking for uninitialized imemo_env.
RUBY_INTERNAL_EVENT_NEWOBJ can expose uninitialized imemo_env
objects and marking it will cause critical error. This patch
skips marking on uninitialized imemo_env.

See: http://rubyci.s3.amazonaws.com/centos7/ruby-master/log/20210329T183003Z.fail.html.gz

Shortest repro-code is provided by mame-san.
2021-03-31 19:18:32 +09:00
Tom Stuart
8b2f2a707d [ruby/openssl] Use #ifdef consistently for HAVE_RB_EXT_RACTOR_SAFE
We previously used a mix of both `#if` and `#ifdef`, but the latter is
more reliable because it will still work if the macro is undefined.

https://github.com/ruby/openssl/commit/e4a622e67e
2021-03-31 18:05:08 +09:00
Tom Stuart
5ab2625243 [ruby/openssl] Fix OpenSSL::Engine build on Debian
On Debian 9 (“stretch”) the `OPENSSL_NO_STATIC_ENGINE` macro is not
defined, which causes all the `#if HAVE_ENGINE_LOAD_…` directives to
fail with `error: 'HAVE_ENGINE_LOAD_…' is not defined, evaluates to 0
[-Werror,-Wundef]` while building TruffleRuby.

We can accomplish the same thing with `#ifdef`, which (of course) works
fine when the `HAVE_ENGINE_LOAD…` macros are also undefined.

Upstreamed from , which fixed
.

https://github.com/ruby/openssl/commit/65e2adf1ac
2021-03-31 18:05:08 +09:00
Kazuki Yamaguchi
e2bf3659e1 [ruby/openssl] pkcs7: keep private key when duplicating PKCS7_SIGNER_INFO
ASN1_dup() will not copy the 'pkey' field of a PKCS7_SIGNER_INFO object
by design; it is a temporary field kept until the PKCS7 structure is
finalized. Let's bump reference counter of the pkey in the original
object and use it in the new object, too.

This commit also removes PKCS7#add_signer's routine to add the
content-type attribute as a signed attribute automatically. This
behavior was not documented or tested. This change should not break any
working user code since the method was completely useless without the
change above.

https://github.com/ruby/openssl/commit/20ca7a27a8
2021-03-31 18:05:07 +09:00
aycabta
66d2fc7989 Enclose the code that was accidentally a link in "tt" 2021-03-31 15:18:52 +09:00
git
d977849e1c * 2021-03-31 [ci skip] 2021-03-31 00:09:39 +09:00
Nobuyoshi Nakada
94d564077c
Text files should end with a newline 2021-03-30 23:41:21 +09:00
Nobuyoshi Nakada
5cdf99f64e
mkmf: fixed install directories of header files in extension libraries [Bug ]
When installing an extension library which provides a header, that
header should be installed under site_ruby (or vendor_ruby when
"--vendor" option was given to extconf.rb).  However, currently
this file is about to be installed in the core include directory.
2021-03-30 23:28:49 +09:00
Kazuhiro NISHIYAMA
9713acd731
Fix coroutine_type variable name 2021-03-30 20:58:34 +09:00
Samuel Williams
a9c5c2d614 Check errno before invoking scheduler in rb_io_wait_readable/writable.
See <https://bugs.ruby-lang.org/issues/17527> for more details.
2021-03-30 23:16:59 +13:00
Samuel Williams
611e711085 Test incorrect behaviour of rb_io_wait_readable/writable. 2021-03-30 23:16:59 +13:00
Samuel Williams
b507f65d44 Support for native riscv64 coroutines. 2021-03-30 19:23:17 +13:00
Samuel Williams
3d32c21758 Disable public interface for now. 2021-03-30 18:38:42 +13:00
Samuel Williams
92449e0e99 Fix handling of timeout accessing scheduler outside of non-blocking context. 2021-03-30 18:38:42 +13:00
Samuel Williams
af1c587546 Improve timeout tests. 2021-03-30 18:38:42 +13:00
Samuel Williams
511acba4ae Update method name and add documentation. 2021-03-30 18:38:42 +13:00
Samuel Williams
09c865d541 Fix native implementation.
# Conflicts:
#	scheduler.c
2021-03-30 18:38:42 +13:00
Nobuyoshi Nakada
67f60ebb64 Fixed a compilation error 2021-03-30 18:38:42 +13:00
Samuel Williams
c05dd7dc85 Prefer rb_check_funcall. 2021-03-30 18:38:42 +13:00
Samuel Williams
9b9bbaec11 Update lib/timeout.rb
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2021-03-30 18:38:42 +13:00
Samuel Williams
4c53dc970b Add hook for Timeout.timeout. 2021-03-30 18:38:42 +13:00
git
93753d7ee7 * 2021-03-30 [ci skip] 2021-03-30 14:28:04 +09:00
Aleksandar Ivanov
d65d661151 [ruby/irb] Prevent the completion from crashing if rdoc is missing
There are cases where ruby is installed without rdoc and e.g.
lib/irb/cmd/help.rb also handles the LoadError

Here is how to replicate the issue:

```
$ docker run -it alpine:3.13.3 sh

/ # apk add ruby ruby-irb ruby-io-console

/ # irb

irb(main):001:0> Class[TAB][TAB]
```

And you end up with something like:

```
irb(main):001:0> ClassTraceback (most recent call last):
        34: from /usr/bin/irb:23:in `<main>'
        33: from /usr/bin/irb:23:in `load'
        32: from /usr/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `<top (required)>'
        31: from /usr/lib/ruby/2.7.0/irb.rb:400:in `start'
        30: from /usr/lib/ruby/2.7.0/irb.rb:471:in `run'
        29: from /usr/lib/ruby/2.7.0/irb.rb:471:in `catch'
        28: from /usr/lib/ruby/2.7.0/irb.rb:472:in `block in run'
        27: from /usr/lib/ruby/2.7.0/irb.rb:537:in `eval_input'
        26: from /usr/lib/ruby/2.7.0/irb/ruby-lex.rb:150:in `each_top_level_statement'
        25: from /usr/lib/ruby/2.7.0/irb/ruby-lex.rb:150:in `catch'
        24: from /usr/lib/ruby/2.7.0/irb/ruby-lex.rb:151:in `block in each_top_level_statement'
        23: from /usr/lib/ruby/2.7.0/irb/ruby-lex.rb:151:in `loop'
        22: from /usr/lib/ruby/2.7.0/irb/ruby-lex.rb:154:in `block (2 levels) in each_top_level_statement'
        21: from /usr/lib/ruby/2.7.0/irb/ruby-lex.rb:182:in `lex'
        20: from /usr/lib/ruby/2.7.0/irb.rb:518:in `block in eval_input'
        19: from /usr/lib/ruby/2.7.0/irb.rb:704:in `signal_status'
        18: from /usr/lib/ruby/2.7.0/irb.rb:519:in `block (2 levels) in eval_input'
        17: from /usr/lib/ruby/2.7.0/irb/input-method.rb:294:in `gets'
        16: from /usr/lib/ruby/2.7.0/forwardable.rb:235:in `readmultiline'
        15: from /usr/lib/ruby/2.7.0/forwardable.rb:235:in `readmultiline'
        14: from /usr/lib/ruby/2.7.0/reline.rb:175:in `readmultiline'
        13: from /usr/lib/ruby/2.7.0/reline.rb:238:in `inner_readline'
        12: from /usr/lib/ruby/2.7.0/reline.rb:238:in `loop'
        11: from /usr/lib/ruby/2.7.0/reline.rb:239:in `block in inner_readline'
        10: from /usr/lib/ruby/2.7.0/reline.rb:270:in `read_io'
         9: from /usr/lib/ruby/2.7.0/reline.rb:270:in `loop'
         8: from /usr/lib/ruby/2.7.0/reline.rb:311:in `block in read_io'
         7: from /usr/lib/ruby/2.7.0/reline.rb:240:in `block (2 levels) in inner_readline'
         6: from /usr/lib/ruby/2.7.0/reline.rb:240:in `each'
         5: from /usr/lib/ruby/2.7.0/reline.rb:241:in `block (3 levels) in inner_readline'
         4: from /usr/lib/ruby/2.7.0/reline/line_editor.rb:820:in `input_key'
         3: from /usr/lib/ruby/2.7.0/reline/line_editor.rb:608:in `complete'
         2: from /usr/lib/ruby/2.7.0/irb/completion.rb:269:in `block in <module:InputCompletor>'
         1: from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- rdoc (LoadError)
```

https://github.com/ruby/irb/commit/a2d299c2ac
2021-03-30 14:27:51 +09:00
Jeremy Evans
62e66aedb0 Add more tests for defined? with method calls 2021-03-29 07:45:15 -07:00
Jeremy Evans
7b3c5ab8a5 Make defined? cache the results of method calls
Previously, defined? could result in many more method calls than
the code it was checking. `defined? a.b.c.d.e.f` generated 15 calls,
with `a` called 5 times, `b` called 4 times, etc..  This was due to
the fact that defined works in a recursive manner, but it previously
did not cache results.  So for `defined? a.b.c.d.e.f`, the logic was
similar to

```ruby
return nil unless defined? a
return nil unless defined? a.b
return nil unless defined? a.b.c
return nil unless defined? a.b.c.d
return nil unless defined? a.b.c.d.e
return nil unless defined? a.b.c.d.e.f
"method"
```

With this change, the logic is similar to the following, without
the creation of a local variable:

```ruby
return nil unless defined? a
_ = a
return nil unless defined? _.b
_ = _.b
return nil unless defined? _.c
_ = _.c
return nil unless defined? _.d
_ = _.d
return nil unless defined? _.e
_ = _.e
return nil unless defined? _.f
"method"
```

In addition to eliminating redundant method calls for defined
statements, this greatly simplifies the instruction sequences by
eliminating duplication.  Previously:

```
0000 putnil                                                           (   1)[Li]
0001 putself
0002 defined                                func, :a, false
0006 branchunless                           73
0008 putself
0009 opt_send_without_block                 <calldata!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0011 defined                                method, :b, false
0015 branchunless                           73
0017 putself
0018 opt_send_without_block                 <calldata!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0020 opt_send_without_block                 <calldata!mid:b, argc:0, ARGS_SIMPLE>
0022 defined                                method, :c, false
0026 branchunless                           73
0028 putself
0029 opt_send_without_block                 <calldata!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0031 opt_send_without_block                 <calldata!mid:b, argc:0, ARGS_SIMPLE>
0033 opt_send_without_block                 <calldata!mid:c, argc:0, ARGS_SIMPLE>
0035 defined                                method, :d, false
0039 branchunless                           73
0041 putself
0042 opt_send_without_block                 <calldata!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0044 opt_send_without_block                 <calldata!mid:b, argc:0, ARGS_SIMPLE>
0046 opt_send_without_block                 <calldata!mid:c, argc:0, ARGS_SIMPLE>
0048 opt_send_without_block                 <calldata!mid:d, argc:0, ARGS_SIMPLE>
0050 defined                                method, :e, false
0054 branchunless                           73
0056 putself
0057 opt_send_without_block                 <calldata!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0059 opt_send_without_block                 <calldata!mid:b, argc:0, ARGS_SIMPLE>
0061 opt_send_without_block                 <calldata!mid:c, argc:0, ARGS_SIMPLE>
0063 opt_send_without_block                 <calldata!mid:d, argc:0, ARGS_SIMPLE>
0065 opt_send_without_block                 <calldata!mid:e, argc:0, ARGS_SIMPLE>
0067 defined                                method, :f, true
0071 swap
0072 pop
0073 leave
```

After change:

```
0000 putnil                                                           (   1)[Li]
0001 putself
0002 dup
0003 defined                                func, :a, false
0007 branchunless                           52
0009 opt_send_without_block                 <calldata!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0011 dup
0012 defined                                method, :b, false
0016 branchunless                           52
0018 opt_send_without_block                 <calldata!mid:b, argc:0, ARGS_SIMPLE>
0020 dup
0021 defined                                method, :c, false
0025 branchunless                           52
0027 opt_send_without_block                 <calldata!mid:c, argc:0, ARGS_SIMPLE>
0029 dup
0030 defined                                method, :d, false
0034 branchunless                           52
0036 opt_send_without_block                 <calldata!mid:d, argc:0, ARGS_SIMPLE>
0038 dup
0039 defined                                method, :e, false
0043 branchunless                           52
0045 opt_send_without_block                 <calldata!mid:e, argc:0, ARGS_SIMPLE>
0047 defined                                method, :f, true
0051 swap
0052 pop
0053 leave
```

This fixes issues where for pathological small examples, Ruby would generate
huge instruction sequences.

Unfortunately, implementing this support is kind of a hack.  This adds another
parameter to compile_call for whether we should assume the receiver is already
present on the stack, and has defined? set that parameter for the specific
case where it is compiling a method call where the receiver is also a method
call.

defined_expr0 also takes an additional parameter for whether it should leave
the results of the method call on the stack.  If that argument is true, in
the case where the method isn't defined, we jump to the pop before the leave,
so the extra result is not left on the stack.  This requires space for an
additional label, so lfinish now needs to be able to hold 3 labels.

Fixes [Bug ]
Fixes [Bug ]
2021-03-29 07:45:15 -07:00
Nobuyoshi Nakada
190a57b168
[ruby/optparse] bump up to 0.1.1
https://github.com/ruby/optparse/commit/2fe984a603
2021-03-29 19:37:25 +09:00
Nobuyoshi Nakada
e8317d90b0
[ruby/optparse] Fixed error message of unparsed non-option
Close https://github.com/ruby/optparse/issues/3

https://github.com/ruby/optparse/commit/94c5cf4032
2021-03-29 19:37:24 +09:00
Nobuyoshi Nakada
2bbae0e91a [ruby/optparse] Completion scripts themselves are not executable
https://github.com/ruby/optparse/commit/65d8aff935
2021-03-29 18:24:58 +09:00
Nobuyoshi Nakada
e97f21afcd [ruby/optparse] Exclude unnecessary files from the package
https://github.com/ruby/optparse/commit/dfd9380231
2021-03-29 18:24:56 +09:00
BurdetteLamar
7846f3201a
[ruby/optparse] Change *opts to *params, to avoid confusion
https://github.com/ruby/optparse/commit/f5f5e202dd
2021-03-29 15:55:41 +09:00
Jeremy Evans
eca8ffaa0b
[ruby/optparse] Add OptionParser#require_exact accessor
This allows you to disable allowing abbreviations of long options
and using short options for long options.

Implements Ruby Feature 

https://github.com/ruby/optparse/commit/dfefb2d2e2
2021-03-29 15:55:41 +09:00
Martin Rey
d474b19b5b
[ruby/optparse] Use ZDOTDIR env var to locate .zshrc
https://github.com/ruby/optparse/commit/c4977674bf
2021-03-29 15:55:41 +09:00
Nobuyoshi Nakada
d87b8ce647
sync_default_gems.rb: ignore COPYING file [ci skip] 2021-03-29 15:19:37 +09:00
Nobuyoshi Nakada
f16b9e7f26
sync_default_gems.rb: IO#puts prints a newline between each argument [ci skip] 2021-03-29 15:14:21 +09:00
Nobuyoshi Nakada
f46bbb2e99
[DOC] Improve an example of Array#count comparison [ci skip] 2021-03-29 11:35:38 +09:00
David CARLIER
875c85a8bd fiber context update for Mac OS.
it is more about memory accounting sake. At allocation time,
 we make clear we re possibly reusing regions marked as reusable.
Noted also calls might not necessarily succeed at first so we do
 only when necessary.
2021-03-29 09:32:40 +13:00
aycabta
a1938ec308 [ruby/irb] Always add input method when calling Irb.new in tests
When passes input method as nil to Context.new through Irb.new,
ReidlineInputMethod.new is executed and the global internal state of Reline is
rewritten, therefore other tests are failed in the Ruby repository. This
commit changes to use TestInputMethod.

https://github.com/ruby/irb/commit/010dce9210
2021-03-29 05:10:08 +09:00
git
1cdecb4349 * 2021-03-29 [ci skip] 2021-03-29 03:18:08 +09:00
Kenichi Kamiya
813c3333a9 [Doc] Fix Array#count comparing strategy 2021-03-28 14:17:52 -04:00
Nobuyoshi Nakada
989e22f394
[ruby/io-console] bump up to 0.5.9
https://github.com/ruby/io-console/commit/302e86a28c
https://github.com/ruby/io-console/commit/0690862526
2021-03-28 23:42:38 +09:00