kasei / attean

A Perl Semantic Web Framework
19 stars 10 forks source link

Iterator->map causes an error if the map changes the object type #156

Open kasei opened 3 years ago

kasei commented 3 years ago

The code in Attean::API::Iterator::map attempts to set the item_type and variables based on the underlying iterator. But if the map block changes the type of objects being returned, the item_type may be wrong, leading to runtime errors. For example:

my $iter    = $model->get_quads()->map(sub { shift->subject });

This will lead to errors such as:

CodeIterator item is not a Attean::API::Quad: Attean::IRI=HASH(0x7f935007eab8) at lib/Attean/CodeIterator.pm line 88.