develooper Front page | perl.perl5.porters | Postings from September 2014

[perl #121392] use VERSION MODULE should not be considered legal

Thread Previous
From:
James E Keenan via RT
Date:
September 24, 2014 01:36
Subject:
[perl #121392] use VERSION MODULE should not be considered legal
Message ID:
rt-4.0.18-2010-1411522596-1953.121392-15-0@perl.org
On Thu Mar 06 13:54:52 2014, kentfredric wrote:
> While reading toke.c a while back, I stumbled upon an unfortunate
> accident.
> 
> use VERSION MODULE;
> use MODULE  VERSION;
> 
> These forms are equivalent.
> 
> And the former form deparses into the latter.
> 
> For example:
> 
> ---
> use 2.000 Moose  # is and requires Moose 2.0
> ---
> 
> And
> ---
> use 5.010
> Moose;
> ---
> 
> Moose version 5.01 required--this is only version 2.1204
> 
> 
> And a grep of CPAN shows that there are a few cases where this might
> occur.
> 
> 
> http://grep.cpan.me/?q=^\s*use\s%2B[v\d.]%2B\s%2B\w  ( Marpa is
> interestingly testing for that exact syntax )
> 

Looking at what's at that link, my impression is that most of the modules on CPAN that display this are Acme::* modules.

> 
> Specifically, when doing this:
> ---
> use 5.010
> use Moose;
> ---
> 
> Which yields the slightly confusing error:
> 
> ---
> "use" not allowed in expression at /tmp/moo.pl line 10, at end of line
> syntax error at /tmp/moo.pl line 10, near "use 5.010
> use Moose"
> ---
> 
> Though thats only failing because it doesn't like you doing this:
> 
> ---
> use 5.010 use;
> ---
> 
> Which is fine in the alternative form
> 
> ---
> use use 5.010
> ---
> 
> 
> Enabling `strict` here changes things slightly:
> 
> ---
> use strict;
> use 5.010 Moose;
> ---
> 
> But ... the error is weird:
> 
> ---
> Bareword "Moose.pm" not allowed while "strict subs" in use at
> /tmp/moo.pl line 9.
> ---
> 
> 
> 
> Fortunately, the odds of triggering a silent bug on a line after a
> 
> ---
> use 5.010
> ---
> 
> Without the trailing semicolon is slim without triggering a subsequent
> error due to keyword-in-expression.
> 
> So the only real risk is people doing
> 
> ---
> use 5.018 featurename
> ---
> 
> Or similar, and erroneously expecting that to be valid syntax, and it
> loading something else unintended.
> 
> For instance
> 
> ---
> use 5.019 subs
> ---
> 
> Giving
> 
> ---
> subs version 5.019 required--this is only version 1.02
> ---
> 
> May invoke confusion.
> 

This ticket has not generated any discussion since it was file 6+ months ago.  Comments?

Thank you very much.


-- 
James E Keenan (jkeenan@cpan.org)

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=121392

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