(https://github.com/ruby/irb/pull/931)
Some helpers, like Rails console's `app`, requires memoization of the
helper's ivars. To support it IRB needs to memoize helper method instances
as well.
a96c7a6668
Some helpers, like Rails console's `app`, requires memoization of the
helper's ivars. To support it IRB needs to memoize helper method instances
as well.
169a9a2c30
(https://github.com/ruby/irb/pull/925)
This module was used to extend both commands and helpers when they're not
separated. Now that they are, and we have a Command module, we should move
command-related logic to the Command module and update related references.
This will make the code easier to understand and refactor in the future.
f74ec97236
debug_readline
(https://github.com/ruby/irb/pull/923)
* Remove exit and exti! command workaround when executed outside of IRB
Command was a method. It could be executed outside of IRB.
Workaround for it is no longer needed.
* Handle IRB_EXIT in debug mode
* Add exit and exit! command in rdbg mode
0b5dd6afd0
In cases where RubyVM::InstructionSequence.load_from_binary() is
passed a param other than a String, we attempt to call the
RSTRING_LENINT macro on it which can cause a segfault.
ex:
```
var_0 = 0
RubyVM::InstructionSequence.load_from_binary(var_0)
```
This commit adds a type check to raise unless we are provided
a String.
[Feature #18576]
Since outright renaming `ASCII-8BIT` is deemed to backward incompatible,
the next best thing would be to only change its `#inspect`, particularly
in exception messages.
(https://github.com/ruby/reline/pull/653)
* Support multiline input in Reline.readline internally, reduce multiline-singleline branch
* Add readline(singleline) prompt test with force inserting multiline text
97846095d7
if a method `foo` uses a block, other (unrelated) method `foo`
can receives a block. So try to relax the unused block warning
condition.
```ruby
class C0
def f = yield
end
class C1 < C0
def f = nil
end
[C0, C1].f{ block } # do not warn
```
This test fail relatively frequently and it's unclear what is
happening.
```
str: {"address":"0x7fbdeb26d4e0", "type":"STRING", "shape_id":1, "slot_size":40, "class":"0x7fbdd1e0ec50", "frozen":true, "embedded":true, "fstring":true, "bytesize":3, "value":"bar", "encoding":"UTF-8", "coderange":"7bit", "memsize":40, "flags":{"wb_protected":true, "old":true, "uncollectible":true, "marked":true}}
bar: {"address":"0x7fbdd0a8b138", "type":"STRING", "shape_id":1, "slot_size":40, "class":"0x7fbdd1e0ec50", "frozen":true, "embedded":true, "fstring":true, "bytesize":3, "value":"bar", "encoding":"UTF-8", "coderange":"7bit", "memsize":40, "flags":{"wb_protected":true}}
```
The `"bar".freeze` literal correctly put an old-gen fstring on the stack.
But `-%w(b a r).join('')` returns a young-gen fstring, which suggest it
somehow failed to find the old one in the `frozen_strings` table.
This could be caused by another test corrupting the table, or corrupting
the `"bar"` fstring.
By using a different literal value we can learn whether the bug is specific
to `"bar"` (used in many tests) or more general.
reads
(https://github.com/ruby/stringio/pull/95)
[[Bug #20418]](https://bugs.ruby-lang.org/issues/20418)
Ruby IO#read preserves the encoding on partial read, but change it when
reading the whole IO
from commit 0ca7036682:
> * io.c (read_all): should associate default external encoding.
> * io.c (io_read): should NOT associate default external encoding.
073172da31
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
## The problem
Currently the tests are executed in the fixed name directory "tmp"
under the top source directory. However it makes the tests fail when
the source path contains symlinks. Or unable to even start if the top
source directory is read-only, e.g., remote-mounting in read-only mode
from virtual machines.
Also, with the fixed directory, there is no way to avoid `pend` in
`TestGemPackage#test_extract_symlink_parent_doesnt_delete_user_dir`.
## The fix
Instead of creating the fixed name directory, this PR allows to use a
different path given with the environment variable "GEM_TEST_TMPDIR".
The default path is, as well as the current behavior, "tmp" from the
top source directory.
### Caveat
It is the caller's responsibility to make the directory safe (owned,
world unwritable, or sticky) when setting the environment variable.
bf00850656
This makes it easier to notice a dependency is causing interpreter or
JIT deoptimization.
```ruby
Warning[:performance] = true
class String
def freeze
super
end
end
```
```
./test.rb:4: warning: Redefining 'String#freeze' disable multiple interpreter and JIT optimizations
```
Not along after 1b830740ba CI
started to rarely fail this test:
```
TestString#test_uplus_minus: Test::Unit::AssertionFailedError: uminus deduplicates [Feature #13077].
1) Failure:
TestString#test_uplus_minus [/tmp/ruby/src/trunk/test/ruby/test_string.rb:3368]:
```
It's unclear what is going on, but one possibility is that
`"bar".freeze` might no longer compile correctly.
Another possibility is that another test redefine `String#freeze`,
causing `opt_str_freeze` to no longer return an `fstring`.
`super(){}`, `super{}` and `super(&b)` doesn't use the given
block so warn unused block warning when calling a method which
doesn't use block with above `super` expressions.
e.g.: `def f = super{B1}` (warn on `f{B2}` because `B2` is not used.
`super()` (not zsuper) passes the passed block and
it can be used.
```ruby
class C0
def foo; yield; end
end
class C1 < C0
def foo; super(); end
end
C1.new.foo{p :block} #=> :block
```
With verbopse mode (-w), the interpreter shows a warning if
a block is passed to a method which does not use the given block.
Warning on:
* the invoked method is written in C
* the invoked method is not `initialize`
* not invoked with `super`
* the first time on the call-site with the invoked method
(`obj.foo{}` will be warned once if `foo` is same method)
[Feature #15554]
`Primitive.attr! :use_block` is introduced to declare that primitive
functions (written in C) will use passed block.
For minitest, test needs some tweak, so use
ea9caafc07
for `test-bundled-gems`.
(https://github.com/ruby/reline/pull/649)
* Fix waiting_proc precedence
* Fix waiting_operator bugs
* Add waiting_proc and vi_waiting_operator test
* Fix vi waiting operator arg number
vi_arg and vi_waiting_operator_arg should be multiplied
* Implement `yy` copies whole line in vi_command mode
* Simplify incremental search cancel test
* Add complex vi test with waiting_proc and vi_waiting_operator, split test input
777dffae1c
(https://github.com/ruby/irb/pull/886)
This is a feature that has been requested for a long time. It is now
possible to define custom commands in IRB.
Example usage:
```ruby
require "irb/command"
class HelloCommand < IRB::Command::Base
description "Prints hello world"
category "My commands"
help_message "It doesn't do more than printing hello world."
def execute
puts "Hello world"
end
end
IRB::Command.register(:hello, HelloCommand)
```
888643467c
navigation
(https://github.com/ruby/reline/pull/677)
Fixes https://github.com/ruby/reline/pull/675
This commit extracts the upward navigation condition in `LineEditor#input_key` to a new private method, and adds a new alias. This change allows Reline to support upward navigation in when a user has configured `inputrc` to map Shift-Tab to `menu-complete-backward`, a common setting in Bash (>= 4.x).
Instead of special-casing upward navigation in `LineEditor#input_key`, we now allow it to be processed by the branch that calls `process_key`. The extracted method no longer includes the editing mode check since this check is already made by `#wrap_method_call` by the time `#completion_journey_up` (or `#menu_complete_backward`) is called. Since upward navigation is happening in a method other than `#input_key` now, the `completion_occurs` variable that used to be local to `#input_key` is changed to an instance variable so that the new method can change its value. (I see many examples of mutating such instance variables in `LineEditor`, so I assumed this would be an uncontroversial change consistent with the coding practices already in place.)
Test coverage of this change has been added to the emacs and vi `KeyActor` tests.
Many thanks to @ima1zumi for their very helpful comments on #675 which encouraged me to contribute this work!
2ccdb374a4
In cases where `rb_ary_sort_bang` is called with a block and
tmp is an embedded array, we need to account for the block
potentially impacting the capacity of ary.
ex:
```
var_0 = (1..70).to_a
var_0.sort! do |var_0_block_129, var_1_block_129|
var_0.pop
var_1_block_129 <=> var_0_block_129
end.shift(3)
```
The above example can put the array into a corrupted state
resulting in a heap buffer overflow and possible segfault:
```
ERROR: AddressSanitizer: heap-buffer-overflow on address [...]
WRITE of size 560 at 0x60b0000034f0 thread T0 [...]
```
This commit adds a conditional to determine when the capacity
of ary has been modified by the provided block. If this is
the case, ensure that the capacity of ary is adjusted to
handle at minimum the len of tmp.