Calling exists() on args array in the Mojo::Base constructor #195

Closed
alistratov opened this Issue Aug 10, 2011 · 1 comment

Comments

Projects
None yet
2 participants
@alistratov

In the Mojo::Base, line 55, method new():

exists $_[0] ? exists $_[1] ? {@_} : {%{$_[0]}} : {},

Calling exists() on array values is deprecated since perl 5.12.
Additionally, if we send undefined value for the first member in the constructor's args list (so, exists $_[1] will be false), we will get an error.

Sample code:

use strict;
use warnings;

package Sample;
use Mojo::Base -base;
has 'one';
has 'two';

package main;
my $a = Sample->new( one => undef, two => 2 );
1;

Result:

Can't use string ("one") as a HASH ref while "strict refs" in use at /usr/local/share/perl/5.10.1/Mojo/Base.pm line 55.
@kraih

This comment has been minimized.

Show comment
Hide comment
@kraih

kraih Aug 10, 2011

Owner

Thanks, improved. e33986e

Owner

kraih commented Aug 10, 2011

Thanks, improved. e33986e

@kraih kraih closed this Aug 10, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment