Skip to content

Commit d060070

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 a161529 commit d060070

File tree

7 files changed

+13
-21
lines changed

7 files changed

+13
-21
lines changed

perl.h

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

90499049
#define PERL_STOP_PARSING_AFTER_N_ERRORS 10
90509050

9051-
#define PERL_PARSE_IS_SYNTAX_ERROR_FLAG 128
9052-
#define PERL_PARSE_IS_SYNTAX_ERROR(f) ((f) & PERL_PARSE_IS_SYNTAX_ERROR_FLAG)
9053-
#define PERL_PARSE_ERROR_COUNT(f) ((f) & (PERL_PARSE_IS_SYNTAX_ERROR_FLAG-1))
9051+
#define PERL_PARSE_ERROR_COUNT(f) (f)
90549052

90559053
/*
90569054

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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -1001,10 +1001,10 @@ like $@, _create_mismatch_regexp('main::t081', 4, 2);
10011001
is $a, 123;
10021002

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

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

10091009
sub t084($a,$b){ $a.$b }
10101010
is prototype(\&t084), undef;
@@ -1120,30 +1120,35 @@ eval "#line 8 foo\nsub t095 (\$a, 123) { }";
11201120
is $@, <<EOF;
11211121
A signature parameter must start with '\$', '\@' or '%' at foo line 8, near ", 1"
11221122
syntax error at foo line 8, near ", 123"
1123+
Execution of foo aborted due to compilation errors.
11231124
EOF
11241125

11251126
eval "#line 8 foo\nno warnings; sub t096 (\$a 123) { }";
11261127
is $@, <<'EOF';
11271128
Illegal operator following parameter in a subroutine signature at foo line 8, near "($a 123"
11281129
syntax error at foo line 8, near "($a 123"
1130+
Execution of foo aborted due to compilation errors.
11291131
EOF
11301132

11311133
eval "#line 8 foo\nsub t097 (\$a { }) { }";
11321134
is $@, <<'EOF';
11331135
Illegal operator following parameter in a subroutine signature at foo line 8, near "($a { }"
11341136
syntax error at foo line 8, near "($a { }"
1137+
Execution of foo aborted due to compilation errors.
11351138
EOF
11361139

11371140
eval "#line 8 foo\nsub t098 (\$a; \$b) { }";
11381141
is $@, <<'EOF';
11391142
Illegal operator following parameter in a subroutine signature at foo line 8, near "($a; "
11401143
syntax error at foo line 8, near "($a; "
1144+
Execution of foo aborted due to compilation errors.
11411145
EOF
11421146

11431147
eval "#line 8 foo\nsub t099 (\$\$) { }";
11441148
is $@, <<EOF;
11451149
Illegal character following sigil in a subroutine signature at foo line 8, near "(\$"
11461150
syntax error at foo line 8, near "\$\$) "
1151+
Execution of foo aborted due to compilation errors.
11471152
EOF
11481153

11491154
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
@@ -6178,6 +6178,7 @@ yyl_leftcurly(pTHX_ char *s, const U8 formbrack)
61786178
/* This hack is to get the ${} in the message. */
61796179
PL_bufptr = s+1;
61806180
yyerror("syntax error");
6181+
yyquit();
61816182
break;
61826183
}
61836184
OPERATOR(HASHBRACK);
@@ -12676,15 +12677,6 @@ Perl_yyerror_pvn(pTHX_ const char *const s, STRLEN len, U32 flags)
1267612677
Perl_croak(aTHX_ "%s has too many errors.\n", name);
1267712678
}
1267812679
}
12679-
else {
12680-
/* This is a syntax error, and we should stop compiling. */
12681-
assert(PERL_PARSE_IS_SYNTAX_ERROR(PL_error_count));
12682-
if (errsv) {
12683-
Perl_croak_sv(aTHX_ errsv);
12684-
} else {
12685-
abort_execution(errsv, name);
12686-
}
12687-
}
1268812680
}
1268912681
PL_in_my = 0;
1269012682
PL_in_my_stash = NULL;

0 commit comments

Comments
 (0)