Skip Menu |

This queue is for tickets about the Moo CPAN distribution.

Report information
The Basics
Id: 122940
Status: rejected
Priority: 0/
Queue: Moo

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

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



Subject: Moo object construction problem caused by inheritance ( or something else )
Date: Fri, 01 Sep 2017 12:33:06 +0000
To: bug-Moo [...] rt.cpan.org
From: Илья Зайцев <zaytsew.ilya [...] gmail.com>
Found strange behavior with package inheritance: If module Foo::Bar extends Foo and we want to instantiate $bar calling Foo::Bar->new() we will get an object with only Foo::Bar attributes if in the main package(where we calling new) we have written "use Foo" before "use Foo::Bar" OR if package Foo uses package Foo::Bar. Explanation might be not clear, so, please, look at the repo https://github.com/akaiusagi/foo ( travis https://travis-ci.org/akaiusagi/foo ). Tests can be fixed by changing order of "use Foo" and "use Foo::Bar" or by commenting "use Foo::Bar;" line in Foo package. Am I must not use Foo::Bar package in Foo? Or what is going on? Thanks.
This is a circular require issue. Loading Foo causes Foo::Bar to load before it is completely defined, so it ends up with an incomplete definition. There isn't really anything Moo can do to improve this situation. If you really need this kind of circular require, change the 'use Foo::Bar;' to 'require Foo::Bar;' and move it to the end of the file.
Subject: Re: [rt.cpan.org #122940] Moo object construction problem caused by inheritance ( or something else )
Date: Mon, 04 Sep 2017 09:53:45 +0000
To: bug-Moo [...] rt.cpan.org
From: Илья Зайцев <zaytsew.ilya [...] gmail.com>
Ok, thank you for your answer! My bad. пн, 4 сент. 2017 г. в 11:34, Graham Knop via RT <bug-Moo@rt.cpan.org>: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=122940 > > > This is a circular require issue. Loading Foo causes Foo::Bar to load > before it is completely defined, so it ends up with an incomplete > definition. > > There isn't really anything Moo can do to improve this situation. > > If you really need this kind of circular require, change the 'use > Foo::Bar;' to 'require Foo::Bar;' and move it to the end of the file. >