PROBLEM DESCRIPTION
===================
The child caches a dup of the parent's hooks,
so it does the correct thing after being accessed the first time.
But the first time it is called, it doesn't return its cached duped value,
it returns the parent's value. This causes 2 bugs:
1. The first hook declared will get "lost", because it is declared
to the parent hooks, not the child's hooks. And after that first
accessing, only the child's hooks will be used
2. The parent's hooks (which are probably the ones from
[the default](0ff6fa61d4/lib/pry/config/default.rb (L35-37)))
are going to get hooks declared on them that shouldn't be
(well, presumably shouldn't be, given the explicit check for
this case and duping to avoid it).
So if another config object was initialized with the same parent,
it would wind up with hooks that it didn't want/expect.
I assume all the other keys work fine because they are value objects,
so if anything wanted to change the value, it would reassign the key
to the config object rather than mutating the returned value.
Mutability *sigh* yallknowwhatimsayin
SOLUTION DESCRIPTION
====================
Return the cached duped child value instead of the parent value.
EXAMPLE
=======
This code from
[the docs](0ff6fa61d4/lib/pry/hooks.rb (L8-11))
will not print "hello", because it's being declared to the parent hook.
```ruby
Pry.config.hooks.add_hook(:before_session, :say_hi) { puts "hello" }
```
This code will, b/c it's being declared to the cached, duped child hook.
```ruby
Pry.config.hooks
Pry.config.hooks.add_hook(:before_session, :say_hi) { puts "hello" }
```
ISSUE IMPACT
============
Fixes#1254
Might fix or have something to do with these issues:
* #1244 Totally thought I got it, but then couldn't reproduce again later
and just don't understand how JRuby builds, so might just be a problem
with how I was trying to reproduce it.
* #1171 Maybe, depending on if Eclipse integrates with it using the
hooks, alternatively, could be the same issue as the one above,
they might both still be broken. Or both fixed and I can't figure out
how to prove it. Dunno.
OTHER THOUGHTS
==============
I'm writing Github flavoured markdown,
but I'm not actually sure if it will get rendered as such in the PR.
Esp since git considers leading octothorpes as comments and not headers,
and removes them...
Guess we'll see... bottoms up, friends!