Skip to content

Commit

Permalink
Ensure &await can handle flattenable Iterables
Browse files Browse the repository at this point in the history
Fixes #1323

We don't want to do deconts for the user, as previous commits
tried to fix the issue with, but we still want[^1] to accept whatever
would be accepted by *@ slurpy:

- 6.c: eagerize the map, so nested levels get reified
- 6.d: toss Iterable and Any:D candidates to force these things
    go through the slurpy

Added the test for throwage on `await non-Iterable` to make test
instead of roast, cause of [2].

[1] https://irclog.perlgeek.de/perl6-dev/2017-12-20#i_15604469
[2] https://irclog.perlgeek.de/perl6-dev/2017-12-20#i_15604448
  • Loading branch information
zoffixznet committed Dec 20, 2017
1 parent 7df750a commit ee8ac60
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
11 changes: 0 additions & 11 deletions src/core.d/await.pm
Expand Up @@ -15,9 +15,6 @@ multi sub await() {
multi sub await(Any:U $x) {
die "Must specify a defined Awaitable to await (got an undefined $x.^name())";
}
multi sub await(Any:D $x) {
die "Must specify an Awaitable to await (got a $x.^name())";
}
multi sub await(Awaitable:D \a) {
CATCH {
unless nqp::istype($_, X::Await::Died) {
Expand All @@ -26,14 +23,6 @@ multi sub await(Awaitable:D \a) {
}
$*AWAITER.await(a)
}
multi sub await(Iterable:D \i) {
CATCH {
unless nqp::istype($_, X::Await::Died) {
($_ but X::Await::Died(Backtrace.new(5))).rethrow
}
}
$*AWAITER.await-all(i)
}
multi sub await(*@awaitables) {
CATCH {
unless nqp::istype($_, X::Await::Died) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/asyncops.pm
Expand Up @@ -50,8 +50,8 @@ multi sub await(Supply:D $s) {
my $*RAKUDO-AWAIT-BLOCKING := True;
$*AWAITER.await($s)
}
multi sub await(Iterable:D $i) { $i.eager.map({ await $_ }) }
multi sub await(*@awaitables) { @awaitables.eager.map({await $_}) }
multi sub await(Iterable:D $i) { eager $i.eager.map({ await $_ }) }
multi sub await(*@awaitables) { eager @awaitables.eager.map({await $_}) }

sub awaiterator(@promises) {
Seq.new(class :: does Iterator {
Expand Down

0 comments on commit ee8ac60

Please sign in to comment.