Skip to content

Commit

Permalink
Fix eval 'q;;'
Browse files Browse the repository at this point in the history
The parser expects a semicolon at the end of every statement, so the
lexer provides one.  It was not doing so for evals ending with a
semicolon, even if that semicolon was not a statement-terminating
semicolon.
  • Loading branch information
Father Chrysostomos committed Aug 28, 2012
1 parent 13bce05 commit 1107659
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 4 additions & 1 deletion t/base/lex.t
@@ -1,6 +1,6 @@
#!./perl

print "1..65\n";
print "1..66\n";

$x = 'x';

Expand Down Expand Up @@ -323,3 +323,6 @@ eval '/(?{print <<END
ok 65 - here-doc in re-eval in string eval
END
})/';
eval 'print qq ;ok 66 - eval ending with semicolon\n;'
or print "not ok 66 - eval ending with semicolon\n";
3 changes: 1 addition & 2 deletions toke.c
Expand Up @@ -758,8 +758,7 @@ Perl_lex_start(pTHX_ SV *line, PerlIO *rsfp, U32 flags)
parser->linestr = flags & LEX_START_COPIED
? SvREFCNT_inc_simple_NN(line)
: newSVpvn_flags(s, len, SvUTF8(line));
if (!len || s[len-1] != ';')
sv_catpvs(parser->linestr, "\n;");
sv_catpvs(parser->linestr, "\n;");
} else {
parser->linestr = newSVpvs("\n;");
}
Expand Down

0 comments on commit 1107659

Please sign in to comment.