develooper Front page | perl.perl6.compiler | Postings from February 2018

[perl #132835] "An operation first awaited" error needs to beclearer

From:
David E .
Date:
February 8, 2018 22:34
Subject:
[perl #132835] "An operation first awaited" error needs to beclearer
Message ID:
rt-4.0.24-1271-1518129277-831.132835-82-0@perl.org
# New Ticket Created by  David E. 
# Please include the string:  [perl #132835]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=132835 >


I've wasted more time than I should've the past few days trying to
understand what this message means.  At a minimum the documentation should
be updated, but preferably the error message itself should be clarified.

The example on https://docs.perl6.org/language/traps is not entirely clear,
and did not at all match the scenario I was hitting.  The provided stack
trace also fails to point to the source of the issue.

A trivialized example:

say "Test await after fulfillment";
my $p = Promise.new();
my $vow = $p.vow;
$vow.break(1);
await $p;

Results in:

An operation first awaited:
  in block <unit> at ../test.pl6 line 5

Died with the exception:
    1
      in block <unit> at ../test.pl6 line 5



This haiku-like message simply means that the Promise/Vow has been broken.
Farther, the exception points to the "await $p" line, when it's really the
"$vow.break" line that's responsible for the trouble.

I'd suggest a better error message in this case (if possible) would be
something like:

*A Promise was broken by ../test.pl6 line 4 awaited upon*
  in block <unit> at ../test.pl6 line 5

Died with the exception:
    1
      in block <unit> at ../test.pl6 line 5



Just trying to do my part to make Perl6 better ;-)
- David



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About