# New Ticket Created by Zefram # Please include the string: [perl #126115] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=126115 >
Failure.new is a perfectly valid value that can be stored in a scalar variable: $ ./perl6 -e 'my $a = Failure.new; say $a.WHICH' Failure|60351944 But if used as the *default* value for a variable, it is not stored, but is treated as an active indication of failure: $ ./perl6 -e 'my $a is default(Failure.new); say $a.WHICH' ===SORRY!=== Error while compiling -e Failed at -e:1 Actually thrown at: in any at src/Perl6/World.nqp:2604 in any ex-handle at src/Perl6/World.nqp:3703 in any apply_trait at src/Perl6/World.nqp:2625 in any at gen/moar/m-Perl6-Actions.nqp:4467 in any declare_variable at gen/moar/m-Perl6-Actions.nqp:2682 in any variable_declarator at gen/moar/m-Perl6-Actions.nqp:2526 in any variable_declarator at src/Perl6/Grammar.nqp:2444 in any declarator at src/Perl6/Grammar.nqp:2310 in any scoped at src/Perl6/Grammar.nqp:2381 in any scope_declarator:sym<my> at ./blib/Perl6/Grammar.moarvm:1 in any scope_declarator at ./blib/Perl6/Grammar.moarvm:1 in any term:sym<scope_declarator> at ./blib/Perl6/Grammar.moarvm:1 in any term at ./blib/Perl6/Grammar.moarvm:1 in any termish at src/Perl6/Grammar.nqp:3641 This is not a case of the variable class rejecting the default value; it's signalling the failure represented by the value. If the variable is given a type constraint that the failure object doesn't satisfy, then an error is correctly generated reporting that mismatch. -zefram