Test ‘Missing name in "my sub"’
Don’t allow name after our/state sub

It was a mistake that this was ever allowed.
padcv op type
Add padcv to Opcode.pm
Increase $Opcode::VERSION to 1.24
Allocate ‘our sub’ in the pad

Currently the name is only allocated there.  Nothing fetches it yet.

Notes on the implementation:

S_pending_ident contains the logic for determining whether $foo or
@foo refers to a lexical or package variable.

yylex defers to S_pending_ident if PL_pending_ident is set.

The KEY_sub case in yylex is changed to set PL_pending_ident instead
of using force_word.  For package variables (including our),
S_pending_ident returns a WORD token, which is the same thing that
force_word produces.  So *that* aspect of this change does not affect
the grammar.  However....

The barestmt rule’s SUB branch begins with ‘SUB startsub subname’.
startsub is a null rule that creates a new sub in PL_compcv via
start_subparse().  subname is defined in terms of WORD and also checks
whether this is a special block, turning on CvSPECIAL(PL_compcv) if
it is.  That flag has to be visible during compilation of the sub.

But for a lexical name, such as ‘our foo’, to be allocated in the
right pad, it has to come *before* startsub, i.e., ‘SUB subname
startsub’.

But subname needs to modify the sub that startsub created, set-
ting the flag.

So I copied (not moved, because MYSUB still uses it) the name-checking
code from the subname rule into the SUB branch of barestmt.  Now that
uses WORD directly instead of invoking subname.  That allows the code
there to set everything up in the right order.
pad.c apidocs: Missing fullstop
Make &foo respect our sub

This changes &foo to go through S_pending_ident (by setting
PL_pending_ident, which causes yylex to defer to S_pending_ident for
the next token) the way $foo and %foo do.

This necessitated reducing the maximum identifier length of &foo from
252 to 251, making it match @foo, $foo, etc.  So somebody’s JAPH might
break. :-)
Allow test_bootstrap.t to run from the top level
Use test.pl in lexsub.t

I thought cmd/ couldn’t use test.pl, but was mistaken.
lexsub.t: Fix a test

This is not testing what I meant it to test: that ‘sub d’ will respect
a preceding ‘our sub d;’.  If ‘sub d’ is in the same package, it makes
no difference, so the test tests nothing.

It turns out this does not work yet.
do.t: Load test.pl at BEGIN time

so that parentheses can be omitted.
Let do.t run from the top level
do-file should not force a bareword

A word following do is forced to be a bareword for do-sub’s sake.  But
if it is going to be interpreted as do-file after all, that does not
make sense.  ‘do subname;’ should call the sub and run the file whose
name it returns, instead of running the file named ‘subname’.
Make do sub() respect our declarations
Fix our sub with proto

yylex must emit exactly one token each time it is called.  Some-
times yylex needs to parse several tokens at once.  That’s what
the various force functions are for.  But that is also what
PL_pending_ident is for.

The various force_next, force_word, force_ident, etc., functions keep
a stack of tokens (PL_nextval/PL_nexttype) that yylex will check imme-
diately when called.

PL_pending_ident is used to track a single identifier that yylex will
hand off to S_pending_ident to handle.

S_pending_ident is the only piece of code for resolving an identi-
fier that could be lexical but could also be a package variable.
force_ident assumes it is looking for a package variable.

force_* takes precedence over PL_pending_ident.

All this means that, if an identifier needs to be looked up in the pad
on the next yylex invocation, it has to use PL_pending_ident, and the
force_* functions cannot be used at the same time.

Not realising that, when I made ‘our sub foo’ store the sub in the
pad I also made ‘our sub foo ($)’ into a syntax error, because it
was being parsed as ‘our sub ($) foo’ (the prototype being ‘forced’);
i.e., the pending tokens were being pulled out of the ‘queue’ in the
wrong order.  (I put queue in quotes, because one queue and one unre-
lated buffer together don’t exactly count as ‘a queue’.)

Changing PL_pending_ident to have precedence over the force stack
breaks ext/XS-APItest/t/swaptwostmts.t, because the statement-parsing
interface does not localise PL_pending_ident.  It could be changed to
do that, but I don’t think it is the right solution.

Having two separate pending token mechanisms makes things need-
lessly fragile.

This commit eliminates the PL_pending_ident mechanism and
modifies S_pending_ident (renaming it in the process to
S_force_ident_maybe_lex) to work with the force mechanism.  I was
going to merge it with force_ident, but the two make incompatible
assumptions that just complicate the code if merged.  S_pending_ident
needs the sigil in the same string buffer, to pass to the pad inter-
face.  force_ident needs to be able to work without a sigil present.

So now we only have one queue for pending tokens and the order is more
predictable.