Skip to content

Commit 21938ae

Browse files
committed
perl.h, pp_ctl.c - switch to standard way of terminating compilation
I did not fully understand the use of yyquit() when I implemented the SYNTAX_ERROR related stuff. It is not needed, and switching to this makes eval compile error messages more consistent.
1 parent 8a84914 commit 21938ae

File tree

7 files changed

+14
-22
lines changed

7 files changed

+14
-22
lines changed

perl.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9094,9 +9094,7 @@ END_EXTERN_C
90949094

90959095
#define PERL_STOP_PARSING_AFTER_N_ERRORS 10
90969096

9097-
#define PERL_PARSE_IS_SYNTAX_ERROR_FLAG 128
9098-
#define PERL_PARSE_IS_SYNTAX_ERROR(f) ((f) & PERL_PARSE_IS_SYNTAX_ERROR_FLAG)
9099-
#define PERL_PARSE_ERROR_COUNT(f) ((f) & (PERL_PARSE_IS_SYNTAX_ERROR_FLAG-1))
9097+
#define PERL_PARSE_ERROR_COUNT(f) (f)
91009098

91019099
/*
91029100

perly.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,8 @@ Perl_yyparse (pTHX_ int gramtype)
488488
yyerrlab:
489489
/* If not already recovering from an error, report this error. */
490490
if (!parser->yyerrstatus) {
491-
yyerror ("syntax error");
491+
yyerror("syntax error");
492+
yyquit();
492493
}
493494

494495

pp_ctl.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,13 +1671,7 @@ Perl_qerror(pTHX_ SV *err)
16711671
Perl_warn(aTHX_ "%" SVf, SVfARG(err));
16721672

16731673
if (PL_parser) {
1674-
STRLEN len;
1675-
char *err_pv = SvPV(err,len);
16761674
++PL_parser->error_count;
1677-
if (memBEGINs(err_pv,len,"syntax error"))
1678-
{
1679-
PL_parser->error_count |= PERL_PARSE_IS_SYNTAX_ERROR_FLAG;
1680-
}
16811675
}
16821676
}
16831677

t/op/eval.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ BEGIN {
66
set_up_inc('../lib');
77
}
88

9-
plan(tests => 162);
9+
plan(tests => 167);
1010

1111
eval 'pass();';
1212

@@ -625,6 +625,7 @@ for("{;", "{") {
625625
eval $_; is $@ =~ s/eval \d+/eval 1/rag, <<'EOE',
626626
Missing right curly or square bracket at (eval 1) line 1, at end of line
627627
syntax error at (eval 1) line 1, at EOF
628+
Execution of (eval 1) aborted due to compilation errors.
628629
EOE
629630
qq'Right line number for eval "$_"';
630631
}

t/op/signatures.t

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,10 +1013,10 @@ like $@, _create_mismatch_regexp('main::t081', 4, 2);
10131013
is $a, 123;
10141014

10151015
eval "#line 8 foo\nsub t082 (, \$a) { }";
1016-
is $@, qq{syntax error at foo line 8, near "(,"\n};
1016+
is $@, qq{syntax error at foo line 8, near "(,"\nExecution of foo aborted due to compilation errors.\n};
10171017

10181018
eval "#line 8 foo\nsub t083 (,) { }";
1019-
is $@, qq{syntax error at foo line 8, near "(,"\n};
1019+
is $@, qq{syntax error at foo line 8, near "(,"\nExecution of foo aborted due to compilation errors.\n};
10201020

10211021
sub t084($a,$b){ $a.$b }
10221022
is prototype(\&t084), undef;
@@ -1132,30 +1132,35 @@ eval "#line 8 foo\nsub t095 (\$a, 123) { }";
11321132
is $@, <<EOF;
11331133
A signature parameter must start with '\$', '\@' or '%' at foo line 8, near ", 1"
11341134
syntax error at foo line 8, near ", 123"
1135+
Execution of foo aborted due to compilation errors.
11351136
EOF
11361137

11371138
eval "#line 8 foo\nno warnings; sub t096 (\$a 123) { }";
11381139
is $@, <<'EOF';
11391140
Illegal operator following parameter in a subroutine signature at foo line 8, near "($a 123"
11401141
syntax error at foo line 8, near "($a 123"
1142+
Execution of foo aborted due to compilation errors.
11411143
EOF
11421144

11431145
eval "#line 8 foo\nsub t097 (\$a { }) { }";
11441146
is $@, <<'EOF';
11451147
Illegal operator following parameter in a subroutine signature at foo line 8, near "($a { }"
11461148
syntax error at foo line 8, near "($a { }"
1149+
Execution of foo aborted due to compilation errors.
11471150
EOF
11481151

11491152
eval "#line 8 foo\nsub t098 (\$a; \$b) { }";
11501153
is $@, <<'EOF';
11511154
Illegal operator following parameter in a subroutine signature at foo line 8, near "($a; "
11521155
syntax error at foo line 8, near "($a; "
1156+
Execution of foo aborted due to compilation errors.
11531157
EOF
11541158

11551159
eval "#line 8 foo\nsub t099 (\$\$) { }";
11561160
is $@, <<EOF;
11571161
Illegal character following sigil in a subroutine signature at foo line 8, near "(\$"
11581162
syntax error at foo line 8, near "\$\$) "
1163+
Execution of foo aborted due to compilation errors.
11591164
EOF
11601165

11611166
eval "#line 8 foo\nsub t101 (\@_) { }";

t/uni/parser.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ eval "sort \x{100}%";
267267
die $@;
268268
EOS
269269
syntax error at (eval 1) line 1, at EOF
270+
Execution of (eval 1) aborted due to compilation errors.
270271
EXPECT
271272

272273
# New tests go here ^^^^^

toke.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6218,6 +6218,7 @@ yyl_leftcurly(pTHX_ char *s, const U8 formbrack)
62186218
/* This hack is to get the ${} in the message. */
62196219
PL_bufptr = s+1;
62206220
yyerror("syntax error");
6221+
yyquit();
62216222
break;
62226223
}
62236224
OPERATOR(HASHBRACK);
@@ -12951,15 +12952,6 @@ Perl_yyerror_pvn(pTHX_ const char *const s, STRLEN len, U32 flags)
1295112952
Perl_croak(aTHX_ "%s has too many errors.\n", name);
1295212953
}
1295312954
}
12954-
else {
12955-
/* This is a syntax error, and we should stop compiling. */
12956-
assert(PERL_PARSE_IS_SYNTAX_ERROR(PL_error_count));
12957-
if (errsv) {
12958-
Perl_croak_sv(aTHX_ errsv);
12959-
} else {
12960-
abort_execution(errsv, name);
12961-
}
12962-
}
1296312955
}
1296412956
PL_in_my = 0;
1296512957
PL_in_my_stash = NULL;

0 commit comments

Comments
 (0)