stevan / promises-perl

An implementation of Promises in Perl
31 stars 29 forks source link

Adding a resolved promise to collect causes an exception #28

Closed oschwald closed 10 years ago

oschwald commented 10 years ago

A simple test case:

use Promises qw( collect deferred );

collect( deferred->resolve->promise );

throws:

Cannot resolve. Already  resolved at /home/greg/perl5/perlbrew/perls/perl-5.16.2/lib/site_perl/5.16.3/Promises/Deferred.pm line 49.

It appears that the collect promise is being resolved both in the loop and at the end of the method:

Cannot resolve. Already  resolved at /home/greg/perl5/perlbrew/perls/perl-5.16.2/lib/site_perl/5.16.3/Promises/Deferred.pm line 49.
    Promises::Deferred::resolve('Promises::Deferred=HASH(0x23a6848)', 'ARRAY(0x23a6a10)') called at /home/greg/perl5/perlbrew/perls/perl-5.16.2/lib/site_perl/5.16.3/Promises.pm line 60
    Promises::collect('Promises::Promise=HASH(0x22b5570)') called at /home/greg/test.pl line 3

I assume this is not the intended behavior.