Skip Menu |

This queue is for tickets about the Moo CPAN distribution.

Report information
The Basics
Id: 120266
Status: resolved
Priority: 0/
Queue: Moo

People
Owner: Nobody in particular
Requestors: bluefeet [...] gmail.com
Cc:
AdminCc:

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



Subject: Extending a non-Moo class has unexpected behavior on blessed new
Date: Wed, 15 Feb 2017 19:30:54 +0000
To: "bug-Moo [...] rt.cpan.org" <bug-Moo [...] rt.cpan.org>
From: Aran Deltac <bluefeet [...] gmail.com>
TEST: package VanillaRS; use base 'DBIx::Class::ResultSet'; package MooRS; use Moo; extends 'DBIx::Class::ResultSet'; package main; use Test2::Bundle::Extended ':v1'; my $vanilla_rs = bless {}, 'VanillaRS'; my $moo_rs = bless {}, 'MooRS'; my $expected_exception = dies { $vanilla_rs->new() }; is( dies { $moo_rs->new() }, "$expected_exception", ); done_testing; OUTPUT: not ok 1 # Failed test at test-rs.pl line 18. # +-------------------------------------------+----+-------------------------------------------+ # | GOT | OP | CHECK | # +-------------------------------------------+----+-------------------------------------------+ # | Can't call method "isa" on an undefined v | eq | DBIx::Class::ResultSet::new_result(): Res | # | alue at /home/aran/local-lib/lib/perl5/DB | | ult object instantiation requires a hashr | # | Ix/Class/ResultSet.pm line 310.\n | | ef as argument at test-rs.pl line 14\n | # +-------------------------------------------+----+-------------------------------------------+ CONCLUSION: Under Moo it seems that the parent classes' new is called with a package name no matter what, even if the child class's new was called on a blessed object. This is unexpected and weird behavior to me, and makes it so that, in my case, DBIx::Class::ResultSet's weird behavior of acting differently if new is called on a package instead of an object be disabled. While I like the removal of weird behavior, my many tens/hundreds of thousands of lines of existing code does not and prevents me from using Moo everywhere I would like. :)
What version of Moo are you using? I believe this was fixed in 2.002_000.
Subject: Re: [rt.cpan.org #120266] Extending a non-Moo class has unexpected behavior on blessed new
Date: Wed, 15 Feb 2017 23:13:58 +0000
To: bug-Moo [...] rt.cpan.org
From: Aran Deltac <bluefeet [...] gmail.com>
Oh man, thought I had tested latest. Latest does indeed NOT have this issue. Sorry for the distraction! On Wed, Feb 15, 2017 at 2:32 PM Graham Knop via RT <bug-Moo@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=120266 > > > What version of Moo are you using? I believe this was fixed in 2.002_000. >