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
Constants/vars changing type after comparison #17078
Comments
From david@pgbackrest.orgCreated by david@pgbackrest.orgIn the following versions of Perl: This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi (CentOS 6) This code fragment: ------------------------ #!/usr/bin/perl use JSON::PP; use constant VERSION => '9.1'; print("constant in JSON before comparison is " . if (VERSION > 9.0) my $version = '9.2'; print("var in JSON before comparison is " . if ($version > 9.1) ------------------------ Returns: $ ./bug.pl But in "This is perl 5, version 28, subversion 2 (v5.28.2) built for $ ./bug.pl vagrant@pgbackrest-test:~$ docker exec -it test-0 perl -v This behavioral difference causes some interesting issues in our We have been unable to find a specific issue or release note that perl -V output below: This is perl 5, version 28, subversion 2 (v5.28.2) built for Copyright 1987-2019, Larry Wall Perl may be copied only under the terms of either the Artistic License Complete documentation for Perl, including FAQ lists, should be found on vagrant@pgbackrest-test:~$ docker exec -it test-0 perl -V Platform: Characteristics of this binary (from libperl): Perl Info
|
From @iabynOn Wed, Jul 03, 2019 at 01:00:49PM -0700, David Steele (via RT) wrote:
Its not clear in your report which behaviours you consider buggy in which Are all the outputs in the first run above "correct", while any outputs -- |
The RT System itself - Status changed from 'new' to 'open' |
From david@pgbackrest.orgHi Dave, On 7/4/19 3:36 AM, Dave Mitchell via RT wrote:
I consider the new behavior in 5.28 to be buggy -- or at least a
Yes -- the range of Perls (5.10 - 5.26) represent all the versions we It appears strings are being converted to numbers after a comparison to Regards, |
From @GrinnzOn Thu, 04 Jul 2019 09:33:40 -0700, david@pgbackrest.org wrote:
JSON::PP is maintained on CPAN so that is probably a better place to discuss this. This was an intentional change in JSON::PP 2.92 to detect numbers better in the usual case, but of course with the lack of typing in Perl, there is no foolproof solution, these are all heuristics. The benefit of the new detection heuristic is the opposite direction: numbers don't suddenly become strings because you interpolated them in a string or printed them. * https://metacpan.org/source/ISHIGAKI/JSON-PP-4.04/Changes#L70-72 -Dan |
From @GrinnzOn Thu, 04 Jul 2019 10:00:12 -0700, grinnz@gmail.com wrote:
As an addendum, you might consider Cpanel::JSON::XS::Type as a way to declare types for your JSON output and avoid relying on heuristics if it's important. -Dan |
From david@pgbackrest.orgHi Dan, On 7/4/19 1:00 PM, Dan Book via RT wrote:
Hmm, OK. Still seems odd that the output varies based on whether a This drives our unit tests nuts because we have always treated version Thanks for pointing me in the right direction. Regards, |
From david@pgbackrest.orgHi Dan, On 7/4/19 1:01 PM, Dan Book via RT wrote:
Thanks for the tip! We're currently migrating off Perl so I don't want to introduce a new Appending '' seems to be working fine in testing so we'll go with that Regards, |
We have completed our migration off of Perl so we are no longer affected by this issue. Feel free to close it. |
Migrated from rt.perl.org#134261 (status was 'open')
Searchable as RT134261$
The text was updated successfully, but these errors were encountered: