Skip Menu |

This queue is for tickets about the Type-Tiny CPAN distribution.

Report information
The Basics
Id: 125839
Status: resolved
Priority: 0/
Queue: Type-Tiny

People
Owner: perl [...] toby.ink
Requestors: ether [...] cpan.org
Cc: DBOOK [...] cpan.org
AdminCc:

Bug Information
Severity: Unimportant
Broken in: (no value)
Fixed in: (no value)



Subject: dev releases are not removing _ from their versions
It is important, when using underscores in $VERSIONs, to strip the underscore from the variable in a subsequent line. for example: $VERSION = '1.002_003'; $VERSION = eval $VERSION; or: $VERSION = '1.002_003'; $VERSION =~ s/_//g; or (this is the form I prefer, as it is compact and avoids eval): $VERSION = '1.002_003'; $VERSION =~ tr/_//d; The important thing is that: 1. the original $VERSION declaration line contains the underscore, as this is the line that ExtUtils::MakeMaker::parse_version and Module::Metadata->_evaluate_version_line use to populate metdata. 2. the actual $VERSION variable used in runtime *does not* contain the underscore, as naive version comparisons that do not use version.pm expect a numeric value. You can see how this assumption fails in your very own unit tests (where the culprit in this case is Data::Dumper): Argument "2.167_02" isn't numeric in numeric gt (>) at t/20-unit/Error-TypeTiny-Assertion/basic.t line 167. Ordinarily I would supply a pull request making this fix, but it appears you use a custom package builder which adds the version declarations, so modifications will have to be made to that code instead to add the correct constructs.
I update versions using the "perl-reversion" tool which comes with Perl::Version. No custom tool for it. Does this cause any practical issues for commonly used tools? This works without issuing any warnings, even under -w: use Type::Tiny 1.000000; Some pretty mainstream modules use version numbers like this for trial released (without removing underscores at runtime) and don't seem to have any issues. The latest trial versions of YAML.pm, Data::Dumper, JSON::PP, Exporter.pm, etc are amongst them.
On Mon Jul 16 05:21:52 2018, TOBYINK wrote: Show quoted text
> I update versions using the "perl-reversion" tool which comes with > Perl::Version. No custom tool for it. > > Does this cause any practical issues for commonly used tools? > > This works without issuing any warnings, even under -w: > > use Type::Tiny 1.000000; > > Some pretty mainstream modules use version numbers like this for trial > released (without removing underscores at runtime) and don't seem to > have any issues. The latest trial versions of YAML.pm, Data::Dumper, > JSON::PP, Exporter.pm, etc are amongst them.
Two things: 1. I recommend against using Perl::Version for perl versions. It does not support bumping decimal number versions correctly. I've written a tool that correctly bumps perl versions called App::RewriteVersion if it's useful. It also does manage the tr/// line automatically when using an underscore version, similar to the Dist::Zilla [RewriteVersion] plugin. 2. This does not cause any issues for properly written tools. What it does cause issues for are naive decimal number comparisons like $VERSION >= 1.02 at runtime. It's still considered polite to accommodate them, given how simple it is to provide.
On Mon Jul 16 12:44:58 2018, DBOOK wrote: Show quoted text
> 1. I recommend against using Perl::Version for perl versions. It does > not support bumping decimal number versions correctly.
Ref: https://rt.cpan.org/Ticket/Display.html?id=54481, https://rt.cpan.org/Ticket/Display.html?id=110074, https://rt.cpan.org/Ticket/Display.html?id=114541: the fundamental issue is that it only supports dotted-decimal versions with 3 parts, and incorrectly interprets decimal numbers in this format for any operation. $ perl-reversion -bump test_reversion.pl Scanning test_reversion.pl 1.9 Setting version to 1.10
I'll take a look at App::RewriteVersion. I've encountered bumping problems with perl-reversion occasionally, usually when switching from a series of stable releases to trial releases or vice versa. But that's easily solved by using the "--set" option to manually specify the next version number, so it's never really been a big issue.
And if I do start doing the tr/// thing, it will probably be in the 1.005_xxx releases to keep the 1.003_xxx ones consistent. So I'll set this to "stalled" for now.
As this issue only affects people running trial versions, and only people who aren't doing a version check properly, I'm not going to fix. If someone's not doing something properly, giving them a warning seems like a beneficial behaviour, not a bug.
On Mon Jul 16 05:21:52 2018, TOBYINK wrote: Show quoted text
> This works without issuing any warnings, even under -w: > > use Type::Tiny 1.000000;
This warns on perl 5.8.
Show quoted text
> This warns on perl 5.8.
Hmmm, that is a problem then.
Fixed in repo. Normally I'd only mark an issue as resolved once it was fixed in a stable release, but I'll make an exception for this as it only affects dev releases. Leaving this script here in case I ever need it again... ############################################################################ use strict; use warnings; use Path::Tiny qw(path); while (my $file = shift) { $file = path $file; my @lines = $file->lines_utf8; my $var; LINE: for my $line (@lines) { if ($line =~ /(\$.*VERSION)\s*=/) { $var = $1; } if ($line =~ /^[\r\n]*$/ and defined $var) { $line = sprintf("\n%s =~ tr/_//d;\n\n", $var); last LINE; } } warn "could not do anything for $file" unless defined $var; $file->spew_utf8(@lines); }