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

[perl #133268] MoarVM with empty CONTROL {}

Thread Previous
From:
brian d foy
Date:
June 8, 2018 22:11
Subject:
[perl #133268] MoarVM with empty CONTROL {}
Message ID:
rt-4.0.24-19194-1528495869-1409.133268-82-0@perl.org
# New Ticket Created by  "brian d foy" 
# Please include the string:  [perl #133268]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=133268 >


While running this program I get a MoarVM panic:

    2 + 2 = 4
    'two' is not numeric
    MoarVM panic: Trying to unwind over wrong handler

The program:

    sub add-two-things ( $first, $second ) {
        CATCH {
            when X::Str::Numeric {
                fail q/One of the arguments wasn't a number/
                }
            }

for $first, $second {
warn "'$_' is not numeric"  unless val($_) ~~ Numeric;
}

        return $first + $second;
        }

    my @items = < 2 2 3 two nine ten 1 37 0 0 >;

    for @items -> $first, $second {
    CONTROL {}
        my $sum = add-two-things( $first, $second );

        put $sum.defined ??
            "$first + $second = $sum" !!
            "You can't add $first and $second";
        }

-- 
brian d foy <brian.d.foy@gmail.com>
http://www.pair.com/~comdog/

Thread Previous


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