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
named arguments in sub signature not filled with values in surrounding where clause #5697
Comments
From @gfldexsub f( | ( :$a) where { dd $a } ) {}; f 42 # OUTPUT«MuConstraint type check failed for parameter '<anon>'in sub f # it should either work or complain that $a is not declared in this scope |
From @jnthnOn Mon Sep 26 15:42:15 2016, gfldex wrote:
Making it work would imply that we move checking of constraints to after unpacking the sub-signature, which would be a change of behavior from today (and mean that you cannot use the where clause to guard the unpack). So that's not really an option; it's useful in both ways, and you can get the other way by simply moving the where clause inside of the sub-signature. $ ./perl6-m -e 'sub f( | ( :$a where { dd $a } ) ) {}; f a => 42' The fail is simply because `dd` returns `Nil`, which is falsey. The problem with "not declared" is that it is declared in that the symbol has already been poked into the symbol table, it's just not yet bound to a value because the where clause runs prior to the unpack. Contrast it with: $ ./perl6-m -e 'sub f( | where { dd $a } (:$a) ) {}; f 42' Which fails as expected. In summary, I'm not at all sure we want to "make it work". Some kind of warning or error that you reference the symbol before it's bound is possible, though I suspect implementing it will involve quite some contortions, as it goes against the one-passing that such errors typically fall out of. /jnthn |
The RT System itself - Status changed from 'new' to 'open' |
Migrated from rt.perl.org#129364 (status was 'open')
Searchable as RT129364$
The text was updated successfully, but these errors were encountered: