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
QRPA: Can't pop from an empty array! #3585
Comments
From @moritzTest file: sub postfix:<_post_l_>($a) is assoc<left> is equiv(&prefix:<+>) { ./perl6 -Ilib foo.pl Maybe also of interest: ./perl6 --ll-exception -Ilib foo.pl the exception comes from this part here: op_infix: |
From zheglov1887@gmail.comNot sure what is causing this (using Perl only a few days). I have the use v6 ; sub prefix:«MYMINUS»($a) is looser(&infix:<MYPLUS>) { # QRPA: Can't pop from an empty array! However the following equivalent example works as expected use v6 ; sub infix:«MYPLUS»(*@a) is assoc('list') is tighter(&prefix:<MYMINUS>) { # prints -6 as expected Output of perl6 --version is Thanks, |
From @FROGGSThe prefix op must be unary, so this works: sub infix:<MYPLUS>(*@a) is assoc('list') { [+] @a } sub prefix:<MYMINUS>($a) is looser(&infix:<MYPLUS>) is assoc('unary') { -$a } say (MYMINUS (1 MYPLUS 2 MYPLUS 3)); # -6 The problem and the weird (LTA) error message turn up when the prefix op has any other assoc, for example: sub prefix:<MYMINUS>($a) is assoc('unary') { -$a }; say (MYMINUS 1); # works I don't what would be the best way to solve that error message. |
The RT System itself - Status changed from 'new' to 'open' |
From @ShimmerFairyThere is no unary associativity, according to S03: Using two ! symbols below generically to represent any pair of operators that Assoc Meaning of $a ! $b ! $c For unaries this is interpreted as: Assoc Meaning of !$a! So on the surface I think the issue here is that rakudo is using a 'unary' associativity as a cheat, rather than correctly implementing unary associativities. (S03 further notes that standard Perl 6 doesn't take advantage of associativity on unaries, since it keeps each level consistently prefix/postfix, which would explain why rakudo can get away with a 'unary' assoc for standard P6) |
From @AlexDanielHeh, what a clusterfuck! OK let's try to untangle this ticket. The second issue mentioned in this ticket (MVMArray: Can't pop from an empty array) was fixed. ✓ Therefore, 「testneeded」. As for the OP, it seems to be fixed too, but the code is probably not supposed to work. See: 'a' _post_l_ ↑ There's whitespace before the postfix and that's not supposed to work. It also doesn't help that the chosen operator is a valid identifier. That said: ===SORRY!=== Error while compiling /home/alex/./deleteme.pm6 As per the last comment, there's no unary associativity, so my best guess is that it is not supposed to work (at least at this point). So we can change the code like the error message suggests: say (_pre_l_ 'a')_post_l_ # OUTPUT: «<(a)>» Note that the other way is not going to work because it looks too much like a method call. But that works! ✓ Here's the output on all releases: https://gist.github.com/Whateverable/f80d6512dedef6a7914d9d24a7f27138 So I'd say 「testneeded」 (that is, two tests needed), but see RT#131099 for further progress on assoc with non-infix ops. |
From @zoffixznet |
@zoffixznet - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#123216 (status was 'resolved')
Searchable as RT123216$
The text was updated successfully, but these errors were encountered: