Skip Menu |

This queue is for tickets about the JSON-Schema CPAN distribution.

Report information
The Basics
Id: 94259
Status: open
Priority: 0/
Queue: JSON-Schema

People
Owner: Nobody in particular
Requestors: tomjudge [...] cisco.com
Cc:
AdminCc:

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



Subject: Useless use of concatenation (.) or string in void context
Date: Thu, 27 Mar 2014 21:13:45 +0000
To: "bug-JSON-Schema [...] rt.cpan.org" <bug-JSON-Schema [...] rt.cpan.org>
From: "Tom Judge (tomjudge)" <tomjudge [...] cisco.com>
Useless use of concatenation (.) or string in void context at /usr/local/lib/perl5/site_perl/5.16/JSON/Schema/Helper.pm line 311 (#1) (W void) You did something without a side effect in a context that does nothing with the return value, such as a statement that doesn't return a value from a block, or the left side of a scalar comma operator. Very often this points not to stupidity on your part, but a failure of Perl to parse your program the way you thought it would. For example, you'd get this if you mixed up your C precedence with Python precedence and said $one, $two = 1, 2; when you meant to say ($one, $two) = (1, 2); Another common error is to use ordinary parentheses to construct a list reference when you should be using square or curly brackets, for example, if you say $array = (1,2); when you should have said $array = [1,2]; The square brackets explicitly turn a list value into a scalar value, while parentheses do not. So when a parenthesized list is evaluated in a scalar context, the comma is treated like C's comma operator, which throws away the left argument, which is not what you want. See perlref for more on this. This warning will not be issued for numerical constants equal to 0 or 1 since they are often used in statements like 1 while sub_with_side_effects(); String constants that would normally evaluate to 0 or 1 are warned about. Useless use of concatenation (.) or string in void context at /usr/local/lib/perl5/site_perl/5.16/JSON/Schema/Helper.pm line 316 (#1) Useless use of concatenation (.) or string in void context at /usr/local/lib/perl5/site_perl/5.16/JSON/Schema/Helper.pm line 339 (#1) Useless use of concatenation (.) or string in void context at /usr/local/lib/perl5/site_perl/5.16/JSON/Schema/Helper.pm line 344 (#1)
Misplaced paren. Here's the patch.
Subject: patch-lib__JSON__Schema__Helper.pm
--- ./lib/JSON/Schema/Helper.pm.orig 2014-05-21 15:43:01.000000000 -0400 +++ ./lib/JSON/Schema/Helper.pm 2014-05-21 15:49:17.000000000 -0400 @@ -308,12 +308,12 @@ if ((defined $schema->{'minimumCanEqual'} and not $schema->{'minimumCanEqual'}) or $schema->{'exclusiveMinimum'}) { - $addError->("must be greater than minimum value '" . $schema->{'minimum'}) . "'" + $addError->("must be greater than minimum value '" . $schema->{'minimum'} . "'") if $value lt $schema->{'minimum'}; } else { - $addError->("must be greater than or equal to minimum value '" . $schema->{'minimum'}) . "'" + $addError->("must be greater than or equal to minimum value '" . $schema->{'minimum'} . "'") if $value le $schema->{'minimum'}; } } @@ -336,12 +336,12 @@ if ((defined $schema->{'maximumCanEqual'} and not $schema->{'maximumCanEqual'}) or $schema->{'exclusiveMaximum'}) { - $addError->("must be less than or equal to maximum value '" . $schema->{'maximum'}) . "'" + $addError->("must be less than or equal to maximum value '" . $schema->{'maximum'} . "'") if $value gt $schema->{'maximum'}; } else { - $addError->("must be less than or equal to maximum value '" . $schema->{'maximum'}) . "'" + $addError->("must be less than or equal to maximum value '" . $schema->{'maximum'} . "'") if $value ge $schema->{'maximum'}; } }
I can confirm that this patch fixes the problem and that JSON::Schema works with the fix in my Real World Use Case(tm) Hope the patched version will be on its way to CPAN soon :-) - Alex
Updated patch for 0.16. This bites me quite hard as some module I can not figure out which makes these warnings fatal :( I'm willing to co-maint this module (PAUSE account RUZ) on the terms you announced in another module. On Mon Jun 09 04:36:13 2014, KAORU wrote: Show quoted text
> I can confirm that this patch fixes the problem and that JSON::Schema > works with the fix in my Real World Use Case(tm) > > Hope the patched version will be on its way to CPAN soon :-) > > - Alex
-- Best regards, Ruslan.
Subject: JSON-Schema-0.016-useless-use-in-void-context.patch
diff -ru JSON-Schema-0.016/lib/JSON/Schema/Helper.pm JSON-Schema-0.016-me/lib/JSON/Schema/Helper.pm --- JSON-Schema-0.016/lib/JSON/Schema/Helper.pm 2014-09-11 17:27:00.000000000 +0400 +++ JSON-Schema-0.016-me/lib/JSON/Schema/Helper.pm 2015-06-02 00:52:21.000000000 +0300 @@ -309,12 +309,12 @@ if ((defined $schema->{'minimumCanEqual'} and not $schema->{'minimumCanEqual'}) or $schema->{'exclusiveMinimum'}) { - $addError->("must be greater than minimum value '" . $schema->{'minimum'}) . "'" + $addError->("must be greater than minimum value '" . $schema->{'minimum'} . "'") if $value lt $schema->{'minimum'}; } else { - $addError->("must be greater than or equal to minimum value '" . $schema->{'minimum'}) . "'" + $addError->("must be greater than or equal to minimum value '" . $schema->{'minimum'} . "'") if $value le $schema->{'minimum'}; } } @@ -337,12 +337,12 @@ if ((defined $schema->{'maximumCanEqual'} and not $schema->{'maximumCanEqual'}) or $schema->{'exclusiveMaximum'}) { - $addError->("must be less than or equal to maximum value '" . $schema->{'maximum'}) . "'" + $addError->("must be less than or equal to maximum value '" . $schema->{'maximum'} . "'") if $value gt $schema->{'maximum'}; } else { - $addError->("must be less than or equal to maximum value '" . $schema->{'maximum'}) . "'" + $addError->("must be less than or equal to maximum value '" . $schema->{'maximum'} . "'") if $value ge $schema->{'maximum'}; } }