Allow CVs to point to HEKs rather than GVs

This will allow named lexical subs to exist independent of GVs.
Increase $B::VERSION to 1.37
Lexical stubs should not AUTOLOAD

There is a feature that allows stubs to fall back to their GVs’
CVs when called.  If I reference a stub, e.g., \&bar, and then
bar is autoloaded, the AUTOLOAD sub assigning *bar = *foo or
*bar = sub {...}, I can still call the stub to which I have a refer-
ence, and it will fall back to the overloaded sub.

That is all fine and dandy, but it causes any stub that references a
GV via its CvGV pointer to call that GV’s CV.  If we name a lexical
sub by pointing its CvGV pointer at the GV whose name we want it to
have, then the lexical sub, if undefined, will try to fall back to an
autoloaded sub.

That causes things to gang agley in cases like this:

    use 5.01;
    sub foo { } # package sub
    state sub foo;
    foo(); # calls lexical sub; falls back to package sub

While we could fix this by flagging the sub and checking for the flag
in pp_entersub (as we do with anonymous subs), it is better simply to
use a HEK, instead of a GV.  Since a GV is quite heavyweight for stor-
ing just a name, I was going to do that anyway, eventually.  Doing it
now fixes a bug.
op.c:newMYSUB: inline var used only once

as of the previous commit
op.c:newMYSUB: Remove unused vars
‘Undefined subroutine &foo called’ for lex subs

instead of just ‘Undefined subroutine called’ without the name.
Make pad_fixup_inner_anons cope with closed-over subs

When a sub starts being parsed, a new CV is created.  When it fin-
ishes, it is stored in its final location.  If there is a stub there
already, the pad is copied to the stub and the body attached thereto.

Since there may be closures inside the sub whose CvOUTSIDE
pointers point to the temporary CV used during compilation,
pad_fixup_inner_anons is called, to reassign all those
CvOUTSIDE pointers.

This happens in cases like this:

    sub f;
    sub f { sub { } }

When a sub closes over a lexical item in an outer sub, the inner sub
gets its own pad entry with the same value as the outer pad entry.

This means that, now that we have lexical subs (currently just state
subs), we can end up with a pad entry (&s) holding a sub whose
CvOUTSIDE does not point to the sub (f) that owns the pad:

    state sub s { }
    sub f { s() }

If the f sub has to reuse a stub, then pad_fixup_inner_anons gets to
see that, and complains bitterly:

$ ./perl -Ilib -E 'state sub s; sub f; sub f { s() }'
Assertion failed: (CvOUTSIDE(innercv) == old_cv), function Perl_pad_fixup_inner_anons, file pad.c, line 2095.
Abort trap
lexsub.t: Fix some tests

I got this working a few commits ago, but the tests mentioned the
wrong sub name.
Don’t say ‘variable &foo’ in warnings

It should be ‘subroutine &foo’.  (It could be ‘subroutine foo’, but we
use both forms elsewhere, and &foo is the easier to implement, the &
already being contained in the pad name.)
perldiag: closure referents → closure references

This goes back to 2ba9eb46.
Clone state subs in anon subs

Since state variables are not shared between closures, but only
between invocations of the same closure, state subs should behave
the same way.

This was a little tricky.  When we clone a sub, we now clone inner
state subs at the same time.  When walking through the pad, cloning
items, we cannot simply clone the inner sub when we see it, because it
may close over things we haven’t cloned yet:

    sub {
        state sub foo;
        my $x
        sub foo { $x }
    }

We can’t just delay cloning it and do it afterwards, because they may
be multiple subs closing over each other:

    sub {
       state sub foo;
       state sub bar;
       sub foo { \&bar }
       sub bar { \&foo }
    }

So *all* the entries in the new pad must be filled before any inner
subs can be cloned.

So what we do is put a stub in place of the cloned sub.   And then
in a second pass clone the inner subs, reusing the stubs from the
first pass.
lexsub.t: Fix another test

The problem with writing to-do tests is that it is very easy to get
the tests wrong, such that they continue to fail even when the prob-
lems they test for are fixed.
Remove & from redef warnings for lex subs

I started to write this, creating a special SV to hold the name with-
out the ampersand, but then never used that SV.

This is just for consistency with package subs.

I also made this slightly more efficient when warnings are off.
dump.c: Dump CvNAME_HEK
op.c:newMYSUB: Pop scope after creating sub

I was popping the scope before creating the sub in order to expose the
parent pad, where the new sub is to be stored.

That can cause problems, since ops may still be created that get
attached to the new sub.  Those ops will end up using the parent sub’s
slab in that case.  If the parent sub does not finish compiling, due
to an error, it may clean out its slab, freeing ops that the inner sub
is using, so the inner sub, when freed, will try to free ops that are
no longer in allocated memory, as the slab is gone.  Most of the time,
the inner ops won’t have been reused for anything, so the op type will
still be OP_FREED, and op_free will do nothing (except a single bad
read).  But debugging builds detect that and fail an assertion.

Popping the scope afterwards actually does simplify things, surpris-
ingly enough.

I was able to produce this bug with a one-liner, but it did not fail
as part of the test suite.  So this fix includes no test.

Since the o variable in newMYSUB is a padop, it can only be freed when
its pad is active.  It is created before the sub, so it cannot be
freed until the scope has been popped, so it has to go at the bot-
tom.  If an error occurs during newMYSUB, opslab_force_free will take
care of it.
First stab at my sub

This does just enough to get things to compile.

They currently do weird things in edge cases, including ‘Bizarre
copy of CODE’.

‘my sub’ now produces a SUB token, and goes through the same grammar
rule as ‘state sub’ and just plain ‘sub’.  The separate MYSUB branch
of the barestmt rule will go soon, as it is now unused.
Add proto magic type

This will be used for storing the prototype CV of a ‘my’ sub.  The
clone needs to occupy the pad entry so that padcv ops will be able to
find it.  That means the clone has to displace its prototype.  In case
the same sub is called recursively, we still need to be able to access
the prototype.
Let state sub fwd decls and nested subs work in anons

I had this working:

state sub foo;
sub other {
    sub foo { # defines the state sub declared outside
        ...
    }
}

But it failed inside an anonymous subroutine:

sub {
    state sub foo;
    sub other {
        sub foo { # defines the state sub declared outside
            ...
        }
    }
}

When an anonymous (or otherwise clonable) sub is cloned, any state
vars, and, likewise, any state subs, inside it are cloned, too.

In the first example above the state sub forward declaration creates
a subroutine stub.  The ‘other’ sub’s ‘sub foo’ declaration creates a
pad entry in other’s pad that closes over the outer foo immediately,
so the same stub is visible in two pads.  The sub foo {} declaration
uses that stub.

When the outer sub containing the forward declaration is clonable,
the pad entry is not closed over immediately at compile time, because
the pad entry is just a prototype, not the actual value that will be
shared by the clone and its nested subs.  So the inner pad entry does
not contain the sub.

So the actual creation of the sub, if it only looks at the inner
pad (other’s pad), will not see the stub, and will not attach a
body to it.

This was the result:

$ ./miniperl -e 'CORE::state sub foo; CORE::state sub bar { sub foo {warn called} }; foo()'
called at -e line 1.
$ ./miniperl -e 'sub { CORE::state sub foo; CORE::state sub bar { sub foo {warn called} }; foo() }->()'
Undefined subroutine &foo called at -e line 1.

This commit fixes that by having newMYSUB follow the CvOUTSIDE chain
to find the original pad entry where it defines the sub, if the for-
ward declaration is occurs outside and has not been closed over yet.
Add introcv op type

This will be used for introducing ‘my’ subs on scope entry, by turning
off the stale flag.
Add clonecv op type

This will be used for cloning a ‘my’ sub on scope entry.
I was going to use pp_padcv for this, but it would end up having a
top-level if/else.