> In perl.git, the branch blead has been updated
>
> <http://perl5.git.perl.org/perl.git/commitdiff/f71d6157c7933c0d3df645f0411d97d7e2b66b2f?hp=0409250f9c9eac87ff80d18e21856800e91763b5>
>
> - Log -----------------------------------------------------------------
> commit f71d6157c7933c0d3df645f0411d97d7e2b66b2f
> Author: Rafael Garcia-Suarez <rgarciasuarez@gmail.com>
> Date: Tue Jul 28 09:47:24 2009 +0200
>
> Forbid labels with keyword names
Jerry D. Hedden wrote:
>> Interesting. This "broke" one of my CPAN modules. Wonder how many
>> others it will affect?
Rafael Garcia-Suarez wrote:
> I guess that only demonstrates that one can never underestimate the
> importance of backwards compatibility. I would never have guessed I
> had such a report that fast.
>
> What was the code you used ?
The construct was something like this:
# Check on what we've found
CHECK:
foreach my $key (keys(%{$spec})) {
my $spec_item = $$spec{$key};
# No specs to check
if (ref($spec_item) ne 'HASH') {
# The specifier entry was just 'key => regex'. If 'key' is not in
# the args, the we need to remove the 'undef' entry in the found
# args hash.
if (! defined($found{$key})) {
delete($found{$key});
}
next CHECK;
}
... and more similar check ...
}
I didn't think of the label as a keyword. I changed it to
CHECKIT to fix the problem.
I don't have a problem with the change itself. I think it's
a good idea. However, the error message you get doesn't
tell you what you did wrong! Consider:
#!/usr/bin/perl
use strict;
use warnings;
CHECK:
foreach (1..3) {
if ($_ == 2) {
next CHECK;
}
}
# EOF
When run, this produces:
syntax error at label.pl line 7, near ":
foreach "
Execution of label.pl aborted due to compilation errors.
It was only because I had just seen this change to blead
that I understood what the errors I was getting were related
to. Otherwise, I would have been scratching my head, and
probably asking for help on perl5-porters.
How about an error message that tells what the problem
really is:
Can't use keyword as a label.
Otherwise, it may become a problem when this change hits the
streets.
Thread Previous
|
Thread Next