Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure.new not accepted as default value #4561

Closed
p6rt opened this issue Sep 20, 2015 · 4 comments
Closed

Failure.new not accepted as default value #4561

p6rt opened this issue Sep 20, 2015 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 20, 2015

Migrated from rt.perl.org#126115 (status was 'resolved')

Searchable as RT126115$

@p6rt
Copy link
Author

p6rt commented Sep 20, 2015

From zefram@fysh.org

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

@p6rt
Copy link
Author

p6rt commented Sep 20, 2015

From @jnthn

On Sun Sep 20 05​:14​:45 2015, zefram@​fysh.org wrote​:

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.

Fixed, and test added in S02-names/is_default.t.

@p6rt
Copy link
Author

p6rt commented Sep 20, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt p6rt closed this as completed Sep 20, 2015
@p6rt
Copy link
Author

p6rt commented Sep 20, 2015

@jnthn - Status changed from 'open' to 'resolved'

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant