Use of literal control characters in variable names is deprecated at (eval 1) line 1.
Use of literal control characters in variable names is deprecated at (eval 2) line 1.
Use of literal control characters in variable names is deprecated at (eval 3) line 1.
-Use of literal control characters in variable names is deprecated at (eval 4) line 1.
+Use of literal control characters in variable names is deprecated at (eval 4) line 2.
Use of literal control characters in variable names is deprecated at (eval 5) line 1.
-Use of literal control characters in variable names is deprecated at (eval 6) line 1.
+Use of literal control characters in variable names is deprecated at (eval 6) line 2.
ok
########
# toke.c
Ambiguous use of ${time{...}} resolved to $time{...} at - line 3.
########
# toke.c
+use warnings 'ambiguous' ;
+$a = ${
+
+ time
+ {2}
+};
+warn "after";
+EXPECT
+Ambiguous use of ${time{...}} resolved to $time{...} at - line 5.
+after at - line 8.
+########
+# toke.c
+use warnings 'ambiguous' ;
+$a = ${
+
+time[2]
+
+};
+$a = ${
+
+time
+ [2]
+
+};
+warn "after";
+EXPECT
+Ambiguous use of ${time[...]} resolved to $time[...] at - line 5.
+Ambiguous use of ${time[...]} resolved to $time[...] at - line 10.
+after at - line 14.
+########
+# toke.c
no warnings 'ambiguous' ;
$a = ${time{2}};
EXPECT
########
# toke.c
use warnings 'ambiguous' ;
+$a = ${
+time
+} ;
+$a = @{
+time
+} ;
+$a = $#{
+time
+} ;
+$a = %{
+time
+} ;
+$a = *{
+time
+} ;
+$a = defined &{
+time
+
+
+} ;
+warn "last";
+EXPECT
+Ambiguous use of ${time} resolved to $time at - line 4.
+Ambiguous use of @{time} resolved to @time at - line 7.
+Ambiguous use of @{time} resolved to @time at - line 10.
+Ambiguous use of %{time} resolved to %time at - line 13.
+Ambiguous use of *{time} resolved to *time at - line 16.
+Ambiguous use of &{time} resolved to &time at - line 19.
+last at - line 23.
+########
+# toke.c
+use warnings 'ambiguous' ;
sub fred {}
$a = ${fred} ;
no warnings 'ambiguous' ;
require './test.pl';
}
-plan 30;
+plan 32;
my @warnings;
my $wa = []; my $ea = [];
is @warnings, 2;
is $warnings[1], $warnings[0], 'warn treats $@=3 and $@="3" the same way';
+fresh_perl_is(<<'EOF', "should be line 4 at - line 4.\n", {stderr => 1}, "");
+${
+ foo
+} = "should be line 4";
+warn $foo;
+EOF
+
+TODO: {
+ local $::TODO = "Line numbers don't yet match up for \${ EXPR }";
+ my $expected = <<'EOF';
+line 1 at - line 1.
+line 4 at - line 3.
+also line 4 at - line 4.
+line 5 at - line 5.
+EOF
+ fresh_perl_is(<<'EOF', $expected, {stderr => 1}, "");
+warn "line 1";
+(${
+ foo
+} = "line 5") && warn("line 4"); warn("also line 4");
+warn $foo;
+EOF
+}
+
1;
char *d = dest;
char * const e = d + destlen - 3; /* two-character token, ending NUL */
bool is_utf8 = cBOOL(UTF);
+ I32 orig_copline, tmp_copline = 0;
PERL_ARGS_ASSERT_SCAN_IDENT;
if (*s == '{') {
bracket = s;
s++;
- while (s < PL_bufend && ( SPACE_OR_TAB(*s) || *s == '\n' ))
- s++;
+ orig_copline = CopLINE(PL_curcop);
+ while (s < PL_bufend && isSPACE(*s)) {
+ s = PEEKSPACE(s);
+ }
}
/* Is the byte 'd' a legal single character identifier name? 'u' is true
d += is_utf8 ? UTF8SKIP(d) : 1;
parse_ident(&s, &d, e, 1, is_utf8);
*d = '\0';
- while (s < PL_bufend && SPACE_OR_TAB(*s))
- s++;
+ tmp_copline = CopLINE(PL_curcop);
+ while (s < PL_bufend && isSPACE(*s)) {
+ s = PEEKSPACE(s);
+ }
if ((*s == '[' || (*s == '{' && strNE(dest, "sub")))) {
/* ${foo[0]} and ${foo{bar}} notation. */
if (ckWARN(WARN_AMBIGUOUS) && keyword(dest, d - dest, 0)) {
const char * const brack =
(const char *)
((*s == '[') ? "[...]" : "{...}");
+ orig_copline = CopLINE(PL_curcop);
+ CopLINE_set(PL_curcop, tmp_copline);
/* diag_listed_as: Ambiguous use of %c{%s[...]} resolved to %c%s[...] */
Perl_warner(aTHX_ packWARN(WARN_AMBIGUOUS),
"Ambiguous use of %c{%s%s} resolved to %c%s%s",
funny, dest, brack, funny, dest, brack);
+ CopLINE_set(PL_curcop, orig_copline);
}
bracket++;
PL_lex_brackstack[PL_lex_brackets++] = (char)(XOPERATOR | XFAKEBRACK);
*d = '\0';
}
- while (s < PL_bufend && ( SPACE_OR_TAB(*s) || *s == '\n' ))
- s++;
-
+ if ( !tmp_copline )
+ tmp_copline = CopLINE(PL_curcop);
+ while (s < PL_bufend && isSPACE(*s)) {
+ s = PEEKSPACE(s);
+ }
+
/* Expect to find a closing } after consuming any trailing whitespace.
*/
if (*s == '}') {
SVs_TEMP | (is_utf8 ? SVf_UTF8 : 0) );
if (funny == '#')
funny = '@';
+ orig_copline = CopLINE(PL_curcop);
+ CopLINE_set(PL_curcop, tmp_copline);
Perl_warner(aTHX_ packWARN(WARN_AMBIGUOUS),
"Ambiguous use of %c{%"SVf"} resolved to %c%"SVf,
funny, tmp, funny, tmp);
+ CopLINE_set(PL_curcop, orig_copline);
}
}
}
/* Didn't find the closing } at the point we expected, so restore
state such that the next thing to process is the opening { and */
s = bracket; /* let the parser handle it */
+ CopLINE_set(PL_curcop, orig_copline);
*dest = '\0';
}
}