[perl #133524] report line number for Prototype not terminated
authorTony Cook <tony@develop-help.com>
Wed, 2 Jan 2019 00:20:34 +0000 (11:20 +1100)
committerTony Cook <tony@develop-help.com>
Wed, 2 Jan 2019 00:20:34 +0000 (11:20 +1100)
Previously COPLINE was updated (to the end of the file) before
reporting the error, which wasn't useful.

t/lib/croak/toke
toke.c

index 4a01c7a..59c377b 100644 (file)
@@ -487,3 +487,9 @@ dump;
 CORE::dump;
 EXPECT
 dump() must be written as CORE::dump() as of Perl 5.30 at - line 2.
+########
+# NAME check Prototype not terminated includes line number (133524)
+sub t1 {}
+sub t2 (}
+EXPECT
+Prototype not terminated at - line 2.
diff --git a/toke.c b/toke.c
index 0527bd8..844de04 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -8738,9 +8738,9 @@ Perl_yylex(pTHX)
                /* Look for a prototype */
                if (*s == '(' && !is_sigsub) {
                    s = scan_str(s,FALSE,FALSE,FALSE,NULL);
-                   COPLINE_SET_FROM_MULTI_END;
                    if (!s)
                        Perl_croak(aTHX_ "Prototype not terminated");
+                   COPLINE_SET_FROM_MULTI_END;
                    (void)validate_proto(PL_subname, PL_lex_stuff,
                                         ckWARN(WARN_ILLEGALPROTO), 0);
                    have_proto = TRUE;