Spec started failing because a statement which we expected to be a
syntax error is now interpreted as a valid pattern-matching statement.
Swapping the hash-rockets for colons turns this back into a syntax
error.
Undefining a nonexistent definition is an error in Ruby. This has not been a problem because there always was `Object#=~` predefined. But we are planning to delete that useless method. This would become an error unless properly guarded.
Returning `nil` on unknown option was default behaviour for Pry v0.12.x. In
e5556a2be8 I changed that but I am not sure if it
was intentional. This breaks plugins such as
pry-theme (https://github.com/kyrylo/pry-theme/issues/59).
Returning `nil` makes more sense, because we can write code like this:
```
Pry.config.foo ||= 123
```
...whereas as of now this is no longer possible and you would need to use
`respond_to?` to achieve the same effect.
This commit improves the appearance of regex aliases in the help index
by storing the result of calling #inspect on the regex as the listing.
For example, consider the `whereami` alias `/whereami[!?]+/`.
Previously this would appear in the help index as
`(?-mix:whereami[!?]+)`. This commit fixes this so it appears as
`/whereami[!?]+/`.
Previously when catching syntax errors in the REPL, we were only showing
the last syntax error displayed by the ruby output. However, ruby can
generate multiple syntax error messages within a single SyntaxException.
For example, this code generates multiple syntax error messages:
```
$ ruby -e 'puts {"key"=>"val"}.to_json'
-e:1: syntax error, unexpected =>, expecting '}'
puts {"key"=>"val"}.to_json
-e:1: syntax error, unexpected '}', expecting end-of-input
puts {"key"=>"val"}.to_json
```
We can't predict which error message would be most helpful for the
consumer - we should show both of them.
This commit modifies the string replacement we're doing when printing
SyntaxExceptions so any number of syntax error lines will be shown
correctly.
Issue: https://github.com/pry/pry/issues/2102
The error message of SyntaxError is different from Ruby's one
Improves on #2086 (Directly delegate internally-used Method methods)
(we add tests here)
Description by @michaelherold
> Relying on `method_missing` for all delegation to `Method` methods means
> that it's easier for the wrong method to be called when gems mess with
> `Object` or other such core areas.
> See https://github.com/ankane/ownership/pull/3 for an example of this.
> By defining explicit delegators, at least for the methods that we use
> internally withing Pry, we can eliminate this issue and be more
> communicative around the methods on the `Pry::Method` class.
I omitted the `source_location` changes because they need some clarification.
The spec was failing because on 2.7 hash directly return nil without
hashing the key if they are empty:
```ruby
m = Module.new do
def self.hash; end
end
h = {}
h[m] # => nil
h[1] = 2
h[m] # => ArgumentError
```
So we need to require IRB so that the to_ignore set isn't empty
Fixes#2099 ($SAFE will become a normal global variable in Ruby 3.0)
MRI < 2.7 supports `$SAFE` variable, which is associated with
taint/untaint methods. All of that is deprecated in 2.7 with a lot of
warning messages generated, and no other effect.
None of this is supported on other Ruby platforms.
Related Ruby ticket:
https://bugs.ruby-lang.org/issues/8468