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
infix:<o> always returns a Block with .arity 0 and .count Inf #6112
Comments
From @smls my &a = *+1; say &a.arity; # 1 say &a.count; # 1 Ideally, the result of the `o` operator should probably have the same Things that care about arity/count, and thus might currently behave .sort (comparator vs Schwartzian transform) |
From @zoffixznetOn Tue, 28 Feb 2017 14:41:07 -0800, smls75@gmail.com wrote:
I have a patch (attached). That solves this ticket and passes all stresstests: cpan@perlbuild2~/CPANPRC/rakudo (nom)$ ./perl6 -e 'm: say ([o] {$_ xx 3} xx 3)(5)' However, it has a definite stench of an evil hack about it, so I'll leave it for someone who knows more about the internals to figure out whether it can be committed. One example of evil weirdness: the `.signature` becomes the sub's signature (e.g. `($a, $b)`), but the block still uses `|args` capture to pass around args? waaaat... |
From @zoffixznetinfix-o.diffdiff --git a/src/core/operators.pm b/src/core/operators.pm
index f5da866..d1661e0 100644
--- a/src/core/operators.pm
+++ b/src/core/operators.pm
@@ -726,7 +726,14 @@ multi sub trait_mod:<is>(Routine $r, Str :$looser!) {
proto sub infix:<∘> (&?, &?) {*}
multi sub infix:<∘> () { *.self }
multi sub infix:<∘> (&f) { &f }
-multi sub infix:<∘> (&f, &g --> Block) { (&f).count > 1 ?? -> |args { f |g |args } !! -> |args { f g |args } }
+multi sub infix:<∘> (&f, &g --> Block) {
+ my \ret = &f.count > 1
+ ?? -> |args { f |g |args }
+ !! -> |args { f g |args }
+ nqp::bindattr(ret, Code, '$!signature',
+ nqp::getattr(nqp::decont(&g), Code, '$!signature'));
+ ret;
+}
my &infix:<o> := &infix:<∘>;
# vim: ft=perl6 expandtab sw=4
|
The RT System itself - Status changed from 'new' to 'open' |
From @zoffixznetP.S.: RT seems to be messing up Unicode ∘ char in the patch above. Download the file, don't copy-paste from this page. |
From @zoffixznetOn Tue, 28 Feb 2017 14:41:07 -0800, smls75@gmail.com wrote:
Thank you for the report. This is now fixed. |
@zoffixznet - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#130891 (status was 'resolved')
Searchable as RT130891$
The text was updated successfully, but these errors were encountered: