New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inconsistent warnings #1509
Comments
From tchrist@chthon.perl.comOne is no longer warned about this: $int = 1; Nor about this: print "I have ${int} warning.\n"; But one *is* still warned about this: print "I have ", ${int}, " warning.\n"; $int = 1; Nor about this: $int = 1; But one *is* still warned about this: $int = 1; This has been the state of world since Summer of '98, at --tom |
From tchrist@chthon.perl.comperl Stupid bugger. And you wonder why I don't use this thing. ------- Forwarded Message Date: Sun, 26 Mar 2000 20:07:47 MST This email address is for reporting bugs to the perl community via perlbug@perl. $int = 1; Nor about this: print "I have ${int} warning.\n"; But one *is* still warned about this: print "I have ", ${int}, " warning.\n"; $int = 1; Nor about this: $int = 1; But one *is* still warned about this: $int = 1; This has been the state of world since Summer of '98, at - --tom
------- End of Forwarded Message |
@rspier - Status changed from 'open' to 'resolved' |
From @schwern[tchrist <!--c--> <i>at</i> <!--a--> chthon.perl.com - Sun Mar 26 11:07:58 2000]:
Good.
This does cause a warning in 5.6.0, 5.8.0 and 5.8.1 RC 2. $ perl5.8.1 -wle 'print "I have ${int} warning.\n";'
You're warned about the first part, anyway. Not sure why its ambiguous. $ perl5.8.1 -wle 'print "I have ", ${int}, " warning.\n"; $int=1; $name{int} = "check"'
Good.
Again the ambiguous warning. The warning comes from toke.c line 6331, FWIW. |
From tchrist@chthon.perl.com
Because ${int} means ${"int"} not ${int()}, nearly. --tom |
From @jkeenanOn Tue Jul 15 20:01:14 2003, tchrist@chthon.perl.com wrote:
Are there any issues remaining in this ticket? |
From @cpansproutOn Tue Nov 22 19:50:15 2011, jkeenan wrote:
Yes, it’s this inconsistency: $ perl5.15.6 -le 'use warnings "ambiguous"; $name{int}' I think that ambiguous warning should be extirpated. There is no -- Father Chrysostomos |
From @HugmeirOn Wed Jan 11 13:24:59 2012, sprout wrote:
I'm not entirely convinced about removing the warning, at least not use warnings 'ambiguous'; On the other hand, I can't think of any other case where the warning I'm attaching three patches; The first one disables the ${%s} warning |
From @Hugmeir0001-Disable-the-Ambiguous-use-of-.-warning-for-keywords.patchFrom 05feda8e9859af13cc3bb56d024b7c8c0fcc4e4e Mon Sep 17 00:00:00 2001
From: Brian Fraser <fraserbn@gmail.com>
Date: Sat, 5 May 2012 05:39:13 -0300
Subject: [PATCH 1/3] Disable the "Ambiguous use of ${...}" warning for
keywords
---
t/lib/feature/switch | 1 -
t/lib/warnings/toke | 2 +-
toke.c | 5 ++---
3 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/t/lib/feature/switch b/t/lib/feature/switch
index 5da635b..817d8b2 100644
--- a/t/lib/feature/switch
+++ b/t/lib/feature/switch
@@ -137,6 +137,5 @@ use feature 'switch';
@break = ($break = "break");
print ${break}, ${break[0]};
EXPECT
-Ambiguous use of ${break} resolved to $break at - line 5.
Ambiguous use of ${break[...]} resolved to $break[...] at - line 5.
breakbreak
diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke
index dd8dc3d..21bd821 100644
--- a/t/lib/warnings/toke
+++ b/t/lib/warnings/toke
@@ -408,7 +408,7 @@ $a = ${time} ;
no warnings 'ambiguous' ;
$a = ${time} ;
EXPECT
-Ambiguous use of ${time} resolved to $time at - line 3.
+
########
# toke.c
use warnings 'ambiguous' ;
diff --git a/toke.c b/toke.c
index 1d18550..3aa5efb 100644
--- a/toke.c
+++ b/toke.c
@@ -8979,9 +8979,8 @@ S_scan_ident(pTHX_ register char *s, register const char *send, char *dest, STRL
PL_expect = XREF;
}
if (PL_lex_state == LEX_NORMAL) {
- if (ckWARN(WARN_AMBIGUOUS) &&
- (keyword(dest, d - dest, 0)
- || get_cvn_flags(dest, d - dest, UTF ? SVf_UTF8 : 0)))
+ if (ckWARN(WARN_AMBIGUOUS)
+ && get_cvn_flags(dest, d - dest, UTF ? SVf_UTF8 : 0))
{
SV *tmp = newSVpvn_flags( dest, d - dest,
SVs_TEMP | (UTF ? SVf_UTF8 : 0) );
--
1.7.9.5
|
From @Hugmeir0002-Ambiguous-use-of-c-s-.-resolved-to-c-s-.-sanity.patchFrom f203bab725c23b09d3447b57750c06cb72fb3840 Mon Sep 17 00:00:00 2001
From: Brian Fraser <fraserbn@gmail.com>
Date: Sat, 5 May 2012 06:08:40 -0300
Subject: [PATCH 2/3] "Ambiguous use of %c{%s[...]} resolved to %c%s[...]"
sanity.
Previously, it would only warn if %s was a keyword. Now it's
consistent with the other 'Ambiguous use' warning, and
triggers if %s is a function.
---
t/lib/feature/switch | 24 ++++++++++++++++++++++--
t/lib/warnings/toke | 22 ++++++++++++++++++++--
toke.c | 12 ++++++++----
3 files changed, 50 insertions(+), 8 deletions(-)
diff --git a/t/lib/feature/switch b/t/lib/feature/switch
index 817d8b2..d2d18fc 100644
--- a/t/lib/feature/switch
+++ b/t/lib/feature/switch
@@ -131,11 +131,31 @@ print ${break}, ${break[0]};
EXPECT
breakbreak
########
-# With the feature, we get an 'Unambiguous use of' warning:
+# Without the feature but declaring break as a sub, 'Ambiguous use of' warning:
use warnings;
-use feature 'switch';
+use subs qw( break );
@break = ($break = "break");
print ${break}, ${break[0]};
EXPECT
+Ambiguous use of ${break} resolved to $break at - line 5.
Ambiguous use of ${break[...]} resolved to $break[...] at - line 5.
breakbreak
+########
+# With the feature, we don't get a 'Ambiguous use of' warning:
+use warnings;
+use feature 'switch';
+@break = ($break = "break");
+print ${break}, ${break[0]};
+EXPECT
+breakbreak
+########
+# With the feature and declaring break as a sub, 'Ambiguous use of' warning:
+use warnings;
+use feature 'switch';
+use subs qw( break );
+@break = ($break = "break");
+print ${break}, ${break[0]};
+EXPECT
+Ambiguous use of ${break} resolved to $break at - line 6.
+Ambiguous use of ${break[...]} resolved to $break[...] at - line 6.
+breakbreak
diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke
index 21bd821..6928541 100644
--- a/t/lib/warnings/toke
+++ b/t/lib/warnings/toke
@@ -58,11 +58,13 @@ toke.c AOK
sort ("")
Ambiguous use of %c{%s%s} resolved to %c%s%s
+ sub time {}
$a = ${time[2]}
$a = ${time{2}}
Ambiguous use of %c{%s} resolved to %c%s
+ sub time {}
$a = ${time}
sub fred {} $a = ${fred}
@@ -388,13 +390,29 @@ $a = ${time[2]};
no warnings 'ambiguous' ;
$a = ${time[2]};
EXPECT
-Ambiguous use of ${time[...]} resolved to $time[...] at - line 3.
+
+########
+# toke.c
+use warnings 'ambiguous' ;
+use subs qw( time );
+$a = ${time[2]};
+no warnings 'ambiguous' ;
+$a = ${time[2]};
+EXPECT
+Ambiguous use of ${time[...]} resolved to $time[...] at - line 4.
+########
+# toke.c
+use warnings 'ambiguous' ;
+$a = ${time{2}};
+EXPECT
+
########
# toke.c
use warnings 'ambiguous' ;
+use subs qw( time );
$a = ${time{2}};
EXPECT
-Ambiguous use of ${time{...}} resolved to $time{...} at - line 3.
+Ambiguous use of ${time{...}} resolved to $time{...} at - line 4.
########
# toke.c
no warnings 'ambiguous' ;
diff --git a/toke.c b/toke.c
index 3aa5efb..10376b4 100644
--- a/toke.c
+++ b/toke.c
@@ -8944,15 +8944,19 @@ S_scan_ident(pTHX_ register char *s, register const char *send, char *dest, STRL
while (s < send && SPACE_OR_TAB(*s))
s++;
if ((*s == '[' || (*s == '{' && strNE(dest, "sub")))) {
- if (ckWARN(WARN_AMBIGUOUS) && keyword(dest, d - dest, 0)) {
+ if (ckWARN(WARN_AMBIGUOUS)
+ && get_cvn_flags(dest, d - dest, UTF ? SVf_UTF8 : 0))
+ {
const char * const brack =
(const char *)
((*s == '[') ? "[...]" : "{...}");
+ SV *tmp = newSVpvn_flags( dest, d - dest,
+ SVs_TEMP | (UTF ? SVf_UTF8 : 0) );
/* 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);
- }
+ "Ambiguous use of %c{%"SVf"%s} resolved to %c%"SVf"%s",
+ funny, tmp, brack, funny, tmp, brack);
+ }
bracket++;
PL_lex_brackstack[PL_lex_brackets++] = (char)(XOPERATOR | XFAKEBRACK);
PL_lex_allbrackets++;
--
1.7.9.5
|
From @Hugmeir0003-Remove-the-Ambiguous-sue-of-s-warnings.patchFrom 9ebea17cbe610635b09cffa4e50d276a2cf9d795 Mon Sep 17 00:00:00 2001
From: Brian Fraser <fraserbn@gmail.com>
Date: Sat, 5 May 2012 06:58:59 -0300
Subject: [PATCH 3/3] Remove the "Ambiguous sue of ${%s}" warnings
---
t/lib/feature/switch | 4 ----
t/lib/warnings/toke | 10 +++++-----
toke.c | 29 +----------------------------
3 files changed, 6 insertions(+), 37 deletions(-)
diff --git a/t/lib/feature/switch b/t/lib/feature/switch
index d2d18fc..2efe9d5 100644
--- a/t/lib/feature/switch
+++ b/t/lib/feature/switch
@@ -137,8 +137,6 @@ use subs qw( break );
@break = ($break = "break");
print ${break}, ${break[0]};
EXPECT
-Ambiguous use of ${break} resolved to $break at - line 5.
-Ambiguous use of ${break[...]} resolved to $break[...] at - line 5.
breakbreak
########
# With the feature, we don't get a 'Ambiguous use of' warning:
@@ -156,6 +154,4 @@ use subs qw( break );
@break = ($break = "break");
print ${break}, ${break[0]};
EXPECT
-Ambiguous use of ${break} resolved to $break at - line 6.
-Ambiguous use of ${break[...]} resolved to $break[...] at - line 6.
breakbreak
diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke
index 6928541..92f7308 100644
--- a/t/lib/warnings/toke
+++ b/t/lib/warnings/toke
@@ -399,7 +399,7 @@ $a = ${time[2]};
no warnings 'ambiguous' ;
$a = ${time[2]};
EXPECT
-Ambiguous use of ${time[...]} resolved to $time[...] at - line 4.
+
########
# toke.c
use warnings 'ambiguous' ;
@@ -412,7 +412,7 @@ use warnings 'ambiguous' ;
use subs qw( time );
$a = ${time{2}};
EXPECT
-Ambiguous use of ${time{...}} resolved to $time{...} at - line 4.
+
########
# toke.c
no warnings 'ambiguous' ;
@@ -435,7 +435,7 @@ $a = ${fred} ;
no warnings 'ambiguous' ;
$a = ${fred} ;
EXPECT
-Ambiguous use of ${fred} resolved to $fred at - line 4.
+
########
# toke.c
use warnings 'syntax' ;
@@ -1248,7 +1248,7 @@ $a = ${fr��d} ;
no warnings 'ambiguous' ;
$a = ${fr��d} ;
EXPECT
-Ambiguous use of ${fr��d} resolved to $fr��d at - line 6.
+
########
# toke.c
use utf8;
@@ -1259,7 +1259,7 @@ $a = ${f���} ;
no warnings 'ambiguous' ;
$a = ${f���} ;
EXPECT
-Ambiguous use of ${f���} resolved to $f��� at - line 6.
+
########
# toke.c
use utf8;
diff --git a/toke.c b/toke.c
index 10376b4..8db881b 100644
--- a/toke.c
+++ b/toke.c
@@ -8832,13 +8832,12 @@ S_scan_ident(pTHX_ register char *s, register const char *send, char *dest, STRL
{
dVAR;
char *bracket = NULL;
- char funny = *s++;
register char *d = dest;
register char * const e = d + destlen - 3; /* two-character token, ending NUL */
PERL_ARGS_ASSERT_SCAN_IDENT;
- if (isSPACE(*s))
+ if (isSPACE(*++s))
s = PEEKSPACE(s);
if (isDIGIT(*s)) {
while (isDIGIT(*s)) {
@@ -8944,19 +8943,6 @@ S_scan_ident(pTHX_ register char *s, register const char *send, char *dest, STRL
while (s < send && SPACE_OR_TAB(*s))
s++;
if ((*s == '[' || (*s == '{' && strNE(dest, "sub")))) {
- if (ckWARN(WARN_AMBIGUOUS)
- && get_cvn_flags(dest, d - dest, UTF ? SVf_UTF8 : 0))
- {
- const char * const brack =
- (const char *)
- ((*s == '[') ? "[...]" : "{...}");
- SV *tmp = newSVpvn_flags( dest, d - dest,
- SVs_TEMP | (UTF ? SVf_UTF8 : 0) );
- /* diag_listed_as: Ambiguous use of %c{%s[...]} resolved to %c%s[...] */
- Perl_warner(aTHX_ packWARN(WARN_AMBIGUOUS),
- "Ambiguous use of %c{%"SVf"%s} resolved to %c%"SVf"%s",
- funny, tmp, brack, funny, tmp, brack);
- }
bracket++;
PL_lex_brackstack[PL_lex_brackets++] = (char)(XOPERATOR | XFAKEBRACK);
PL_lex_allbrackets++;
@@ -8982,19 +8968,6 @@ S_scan_ident(pTHX_ register char *s, register const char *send, char *dest, STRL
PL_lex_state = LEX_INTERPEND;
PL_expect = XREF;
}
- if (PL_lex_state == LEX_NORMAL) {
- if (ckWARN(WARN_AMBIGUOUS)
- && get_cvn_flags(dest, d - dest, UTF ? SVf_UTF8 : 0))
- {
- SV *tmp = newSVpvn_flags( dest, d - dest,
- SVs_TEMP | (UTF ? SVf_UTF8 : 0) );
- if (funny == '#')
- funny = '@';
- Perl_warner(aTHX_ packWARN(WARN_AMBIGUOUS),
- "Ambiguous use of %c{%"SVf"} resolved to %c%"SVf,
- funny, tmp, funny, tmp);
- }
- }
}
else {
s = bracket; /* let the parser handle it */
--
1.7.9.5
|
From @cpansproutOn Sat May 05 05:30:43 2012, Hugmeir wrote:
Well, you are changing subject slightly by putting brackets inside the ${sub{0}} # same as ${ +sub { 0; } }
The example above suggests that a warning might still be apposite for
It looks as though we need a fourth option.... -- Father Chrysostomos |
We should do something about this ticket or close it. |
Migrated from rt.perl.org#2723 (status was 'open')
Searchable as RT2723$
The text was updated successfully, but these errors were encountered: