develooper Front page | perl.perl5.porters | Postings from June 2013

[perl #117535] Bogus "Ambiguous use of * resolved as operator *" warning

Thread Previous
From:
Father Chrysostomos via RT
Date:
June 5, 2013 07:27
Subject:
[perl #117535] Bogus "Ambiguous use of * resolved as operator *" warning
Message ID:
rt-3.6.HEAD-2552-1370417262-8.117535-15-0@perl.org
On Mon Jun 03 22:26:24 2013, sprout wrote:
> On Mon Apr 08 10:46:01 2013, nicholas wrote:
> > I'm recording this bug mostly for completeness, not because I expect
> > it to be
> > fixed. The code in question is not really something that has any right
> > to
> > parse, let alone be useful.
> > 
> > $ perl -lwe '$* = \*STDERR; print $*foo'
> > $* is no longer supported at -e line 1.
> > Bareword found where operator expected at -e line 1, near "$*foo"
> >         (Missing operator before foo?)
> > Unquoted string "foo" may clash with future reserved word at -e line
> > 1.
> > Operator or semicolon missing before *foo at -e line 1.
> > Ambiguous use of * resolved as operator * at -e line 1.
> > foo
> > 
> > 
> > and the exit code is 0.
> > 
> > Note that 3 of the 4 warnings from the parser are actually bogus, but
> > the
> > last is utterly incorrect, as there is no multiplication operator
> > anywhere
> > be seen.
> 
> I can trigger the same bug without playing games with print’s indirect
> object:
> 
> $ ./perl -Ilib -e 'foo**foo'
> Operator or semicolon missing before *foo at -e line 1.
> Ambiguous use of * resolved as operator * at -e line 1.
> 
> This is basically the same as bug #76910.
> 
> When the lexer parses a bareword, it looks at the previous character and
> warns if it happens to match /[*%&]/, so ** and && result in this error,

Actually, the bogus message for ** and && could be fixed similarly to
#77240, which was fixed by 898c3bcab476295054cadaceb5ce68aa230a2d46

I wonder whether a variant of that could apply to $*foo.

> as does print $%foo.
> 
> The purpose of the code is to catch *bar *bar or &black &sheep.
> 
> It’s one of these heuristics that is wrong too often (I’ve triggered the
> bogus warning with real code) and probably deserves extirpation, along
> with the crazy @foo{qw# a b c #} warning (ticket #28380).  (Oops, sorry
> for the tirade!)
> 
> There may be other ways to trigger this (ticket’s) warning that I
> haven’t thought of.
> 


-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=117535

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About