In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/dffc502431a92571665171f2d25d28f95339feec?hp=f1c22b9e404ff0489520a75ead67695af4a770d3>
- Log ----------------------------------------------------------------- commit dffc502431a92571665171f2d25d28f95339feec Author: Father Chrysostomos <[email protected]> Date: Tue Sep 16 09:43:31 2014 -0700 Make âNo comma allowedâ respect lex subs $ ./perl -lIlib -XMfeature=:all -e 'sub foo {} print foo,bar' bar $ ./perl -lIlib -XMfeature=:all -e 'state sub foo {} print foo,bar' No comma allowed after filehandle at -e line 1. This commit makes the latter behave like the former. M t/op/lexsub.t M toke.c commit 1402e1ebcb8d82c4d6423a1d27f1f5b6791da0a8 Author: Father Chrysostomos <[email protected]> Date: Tue Sep 16 05:47:17 2014 -0700 lexsub.t: To-do tests for sort lex_sub M t/op/lexsub.t commit b82e18baa5034a22165a614ef091e3248177bf62 Author: Father Chrysostomos <[email protected]> Date: Tue Sep 16 05:32:35 2014 -0700 toke.c: Remove obsolete comment 345b37853 removed the associated parameter. M toke.c ----------------------------------------------------------------------- Summary of changes: t/op/lexsub.t | 26 +++++++++++++++++++++++++- toke.c | 9 ++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/t/op/lexsub.t b/t/op/lexsub.t index 966aa07..91bb15f 100644 --- a/t/op/lexsub.t +++ b/t/op/lexsub.t @@ -7,7 +7,7 @@ BEGIN { *bar::is = *is; *bar::like = *like; } -plan 137; +plan 141; # -------------------- Errors with feature disabled -------------------- # @@ -384,6 +384,19 @@ is runperl(switches => ['-lXMfeature=:all'], state sub x { is +(caller 0)[3], 'x', 'state sub name in caller' } x } +sub _cmp { $a cmp $b } +{ + local $::TODO = ' '; + state sub _cmp { $b cmp $a } + is join(" ", sort _cmp split //, 'lexsub'), 'x u s l e b', + 'sort state_sub LIST' +} +{ + state sub handel { "" } + print handel, "ok ", curr_test(), + " - no 'No comma allowed' after state sub\n"; + curr_test(curr_test()+1); +} # -------------------- my -------------------- # @@ -735,6 +748,17 @@ is runperl(switches => ['-lXMfeature=:all'], my sub x { is +(caller 0)[3], 'x', 'my sub name in caller' } x } +{ + local $::TODO = ' '; + my sub _cmp { $b cmp $a } + is join(" ", sort _cmp split //, 'lexsub'), 'x u s l e b', + 'sort my_sub LIST' +} +{ + my sub handel { "" } + print handel,"ok ",curr_test()," - no 'No comma allowed' after my sub\n"; + curr_test(curr_test()+1); +} # -------------------- Interactions (and misc tests) -------------------- # diff --git a/toke.c b/toke.c index 8a8d187..2c76477 100644 --- a/toke.c +++ b/toke.c @@ -1987,7 +1987,6 @@ S_newSV_maybe_utf8(pTHX_ const char *const start, STRLEN len) * a keyword (do this if the word is a label, e.g. goto FOO) * int allow_pack : if true, : characters will also be allowed (require, * use, etc. do this) - * int allow_initial_tick : used by the "sub" lexer only. */ STATIC char * @@ -8244,12 +8243,20 @@ S_checkcomma(pTHX_ const char *s, const char *name, const char *what) s++; if (*s == ',') { GV* gv; + PADOFFSET off; if (keyword(w, s - w, 0)) return; gv = gv_fetchpvn_flags(w, s - w, ( UTF ? SVf_UTF8 : 0 ), SVt_PVCV); if (gv && GvCVu(gv)) return; + if (s - w <= 254) { + char tmpbuf[256]; + Copy(w, tmpbuf+1, s - w, char); + *tmpbuf = '&'; + off = pad_findmy_pvn(tmpbuf, s-w+1, UTF ? SVf_UTF8 : 0); + if (off != NOT_IN_PAD) return; + } Perl_croak(aTHX_ "No comma allowed after %s", what); } } -- Perl5 Master Repository
