if (ckWARN(WARN_SYNTAX)) {
const line_t oldline = CopLINE(PL_curcop);
- if (PL_parser && PL_parser->copline != NOLINE)
+ if (PL_parser && PL_parser->copline != NOLINE) {
+ /* This ensures that warnings are reported at the first line
+ of the conditional, not the last. */
CopLINE_set(PL_curcop, PL_parser->copline);
+ }
Perl_warner(aTHX_ packWARN(WARN_SYNTAX), "Found = in conditional, should be ==");
CopLINE_set(PL_curcop, oldline);
}
# op.c
use warnings 'syntax' ;
1 if $a = 1 ;
+1 if $a
+ = 1 ;
no warnings 'syntax' ;
1 if $a = 1 ;
+1 if $a
+ = 1 ;
EXPECT
Found = in conditional, should be == at - line 3.
+Found = in conditional, should be == at - line 4.
########
# op.c
use warnings 'syntax' ;