summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2022-09-25 15:09:52 +0200
committerYves Orton <demerphq@gmail.com>2023-02-20 11:34:22 +0800
commit21938ae5a278f0b48443561333c47714921e7566 (patch)
tree62b372c8d2ea947696beeafc9b88be11ad909042
parent8a8491416c79dc8f491c402c013844437c0643eb (diff)
downloadperl-21938ae5a278f0b48443561333c47714921e7566.tar.gz
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.
-rw-r--r--perl.h4
-rw-r--r--perly.c3
-rw-r--r--pp_ctl.c6
-rw-r--r--t/op/eval.t3
-rw-r--r--t/op/signatures.t9
-rw-r--r--t/uni/parser.t1
-rw-r--r--toke.c10
7 files changed, 14 insertions, 22 deletions
diff --git a/perl.h b/perl.h
index 1247788682..4ad758265a 100644
--- a/perl.h
+++ b/perl.h
@@ -9094,9 +9094,7 @@ END_EXTERN_C
#define PERL_STOP_PARSING_AFTER_N_ERRORS 10
-#define PERL_PARSE_IS_SYNTAX_ERROR_FLAG 128
-#define PERL_PARSE_IS_SYNTAX_ERROR(f) ((f) & PERL_PARSE_IS_SYNTAX_ERROR_FLAG)
-#define PERL_PARSE_ERROR_COUNT(f) ((f) & (PERL_PARSE_IS_SYNTAX_ERROR_FLAG-1))
+#define PERL_PARSE_ERROR_COUNT(f) (f)
/*
diff --git a/perly.c b/perly.c
index 20854ae542..fb4abdfcc1 100644
--- a/perly.c
+++ b/perly.c
@@ -488,7 +488,8 @@ Perl_yyparse (pTHX_ int gramtype)
yyerrlab:
/* If not already recovering from an error, report this error. */
if (!parser->yyerrstatus) {
- yyerror ("syntax error");
+ yyerror("syntax error");
+ yyquit();
}
diff --git a/pp_ctl.c b/pp_ctl.c
index 6ee2360f62..b1e06f4d52 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1671,13 +1671,7 @@ Perl_qerror(pTHX_ SV *err)
Perl_warn(aTHX_ "%" SVf, SVfARG(err));
if (PL_parser) {
- STRLEN len;
- char *err_pv = SvPV(err,len);
++PL_parser->error_count;
- if (memBEGINs(err_pv,len,"syntax error"))
- {
- PL_parser->error_count |= PERL_PARSE_IS_SYNTAX_ERROR_FLAG;
- }
}
}
diff --git a/t/op/eval.t b/t/op/eval.t
index f2f06b1a74..6847a5beab 100644
--- a/t/op/eval.t
+++ b/t/op/eval.t
@@ -6,7 +6,7 @@ BEGIN {
set_up_inc('../lib');
}
-plan(tests => 162);
+plan(tests => 167);
eval 'pass();';
@@ -625,6 +625,7 @@ for("{;", "{") {
eval $_; is $@ =~ s/eval \d+/eval 1/rag, <<'EOE',
Missing right curly or square bracket at (eval 1) line 1, at end of line
syntax error at (eval 1) line 1, at EOF
+Execution of (eval 1) aborted due to compilation errors.
EOE
qq'Right line number for eval "$_"';
}
diff --git a/t/op/signatures.t b/t/op/signatures.t
index e3204224e9..bf568023c9 100644
--- a/t/op/signatures.t
+++ b/t/op/signatures.t
@@ -1013,10 +1013,10 @@ like $@, _create_mismatch_regexp('main::t081', 4, 2);
is $a, 123;
eval "#line 8 foo\nsub t082 (, \$a) { }";
-is $@, qq{syntax error at foo line 8, near "(,"\n};
+is $@, qq{syntax error at foo line 8, near "(,"\nExecution of foo aborted due to compilation errors.\n};
eval "#line 8 foo\nsub t083 (,) { }";
-is $@, qq{syntax error at foo line 8, near "(,"\n};
+is $@, qq{syntax error at foo line 8, near "(,"\nExecution of foo aborted due to compilation errors.\n};
sub t084($a,$b){ $a.$b }
is prototype(\&t084), undef;
@@ -1132,30 +1132,35 @@ eval "#line 8 foo\nsub t095 (\$a, 123) { }";
is $@, <<EOF;
A signature parameter must start with '\$', '\@' or '%' at foo line 8, near ", 1"
syntax error at foo line 8, near ", 123"
+Execution of foo aborted due to compilation errors.
EOF
eval "#line 8 foo\nno warnings; sub t096 (\$a 123) { }";
is $@, <<'EOF';
Illegal operator following parameter in a subroutine signature at foo line 8, near "($a 123"
syntax error at foo line 8, near "($a 123"
+Execution of foo aborted due to compilation errors.
EOF
eval "#line 8 foo\nsub t097 (\$a { }) { }";
is $@, <<'EOF';
Illegal operator following parameter in a subroutine signature at foo line 8, near "($a { }"
syntax error at foo line 8, near "($a { }"
+Execution of foo aborted due to compilation errors.
EOF
eval "#line 8 foo\nsub t098 (\$a; \$b) { }";
is $@, <<'EOF';
Illegal operator following parameter in a subroutine signature at foo line 8, near "($a; "
syntax error at foo line 8, near "($a; "
+Execution of foo aborted due to compilation errors.
EOF
eval "#line 8 foo\nsub t099 (\$\$) { }";
is $@, <<EOF;
Illegal character following sigil in a subroutine signature at foo line 8, near "(\$"
syntax error at foo line 8, near "\$\$) "
+Execution of foo aborted due to compilation errors.
EOF
eval "#line 8 foo\nsub t101 (\@_) { }";
diff --git a/t/uni/parser.t b/t/uni/parser.t
index 0df238428f..d3aa745272 100644
--- a/t/uni/parser.t
+++ b/t/uni/parser.t
@@ -267,6 +267,7 @@ eval "sort \x{100}%";
die $@;
EOS
syntax error at (eval 1) line 1, at EOF
+Execution of (eval 1) aborted due to compilation errors.
EXPECT
# New tests go here ^^^^^
diff --git a/toke.c b/toke.c
index a4454fe010..60b17f040a 100644
--- a/toke.c
+++ b/toke.c
@@ -6218,6 +6218,7 @@ yyl_leftcurly(pTHX_ char *s, const U8 formbrack)
/* This hack is to get the ${} in the message. */
PL_bufptr = s+1;
yyerror("syntax error");
+ yyquit();
break;
}
OPERATOR(HASHBRACK);
@@ -12951,15 +12952,6 @@ Perl_yyerror_pvn(pTHX_ const char *const s, STRLEN len, U32 flags)
Perl_croak(aTHX_ "%s has too many errors.\n", name);
}
}
- else {
- /* This is a syntax error, and we should stop compiling. */
- assert(PERL_PARSE_IS_SYNTAX_ERROR(PL_error_count));
- if (errsv) {
- Perl_croak_sv(aTHX_ errsv);
- } else {
- abort_execution(errsv, name);
- }
- }
}
PL_in_my = 0;
PL_in_my_stash = NULL;