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

alistratov opened this Issue Aug 10, 2011 · 1 comment


None yet
2 participants

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 );


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

This comment has been minimized.

Show comment
Hide comment

kraih Aug 10, 2011


Thanks, improved. e33986e


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