Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builder called twice #2

Open
wayan opened this issue Apr 21, 2015 · 1 comment
Open

builder called twice #2

wayan opened this issue Apr 21, 2015 · 1 comment

Comments

@wayan
Copy link

wayan commented Apr 21, 2015

I tried to use Bolts in a simple script and found a case where builder is apparently called twice.

use strict;
use warnings;

package Bar {
    use Bolts;

    artifact foobar => (
        builder => sub {
            warn "BUILDER CALLED with ", join( ' ', map {"$_"} @_), "\n";
            return 'built';
        }
    );
}

package Foo {
    use Bolts;

    has bar => ( is => 'ro', required => 1 );
}

my $foo = Foo->new(bar=>Bar->new);
warn $foo->acquire('bar', 'foobar');

I tried to trace the code, and the following lines in Bolts::Role::RootLocator::acquire seems quite suspicious to me (missing return inside condition?):

# If the $item is a locator, pass control of the process to that
if (@path && $item->$_can('does') && $item->$_does('Bolts::Role::Locator')) {
       $item->acquire(@path, $options);
}
@zostay
Copy link
Owner

zostay commented Apr 21, 2015

Good catch! You are correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants