This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: 'Operator or semicolon missing before %c%s' cleanup.
authorBrian Fraser <fraserbn@gmail.com>
Sat, 6 Aug 2011 07:16:59 +0000 (08:16 +0100)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 23 Mar 2012 03:23:54 +0000 (20:23 -0700)
t/lib/warnings/toke
toke.c

index 5a4af81..4ce6ae4 100644 (file)
@@ -736,6 +736,26 @@ Operator or semicolon missing before *foo at - line 10.
 Ambiguous use of * resolved as operator * at - line 10.
 ########
 # toke.c
+use utf8;
+use open qw( :utf8 :std );
+$^W = 0 ;
+*foo *foo ;
+{
+    no warnings 'ambiguous' ;
+    *foo *foo ;
+    use warnings 'ambiguous' ;
+    *foo *foo ;
+}
+*foo *foo ;
+EXPECT
+Operator or semicolon missing before *foo at - line 5.
+Ambiguous use of * resolved as operator * at - line 5.
+Operator or semicolon missing before *foo at - line 10.
+Ambiguous use of * resolved as operator * at - line 10.
+Operator or semicolon missing before *foo at - line 12.
+Ambiguous use of * resolved as operator * at - line 12.
+########
+# toke.c
 use warnings 'misc' ;
 my $a = "\m" ;
 no warnings 'misc' ;
diff --git a/toke.c b/toke.c
index 9f6c32a..6a7e1ef 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -7042,8 +7042,10 @@ Perl_yylex(pTHX)
            safe_bareword:
                if ((lastchar == '*' || lastchar == '%' || lastchar == '&')) {
                    Perl_ck_warner_d(aTHX_ packWARN(WARN_AMBIGUOUS),
-                                    "Operator or semicolon missing before %c%s",
-                                    lastchar, PL_tokenbuf);
+                                    "Operator or semicolon missing before %c%"SVf,
+                                    lastchar, SVfARG(newSVpvn_flags(PL_tokenbuf,
+                                                    strlen(PL_tokenbuf),
+                                                    SVs_TEMP | (UTF ? SVf_UTF8 : 0))));
                    Perl_ck_warner_d(aTHX_ packWARN(WARN_AMBIGUOUS),
                                     "Ambiguous use of %c resolved as operator %c",
                                     lastchar, lastchar);