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
overloading 'x' is broken #13811
Comments
From @salvaCreated by @salvaCreate the following module: ------------overx.pm-------------------- package overx; require overload; sub new { sub _x { sub _length { sub _to_string { 1; ------------end-of-overx.pm-------------------- and run... $ perl -I. -Moverx -MData::Dumper -e '$a = overx->new(1,'a'); print Dumper [$a, scalar(($a x $a) x $a)]' I get... {1, a} x {1, a} -> {1, a, 1, a} when expecting... {1, a} x {1, a} -> {1, a, 1, a} Other operators work as expected. For instance, the following generates the expected result. perl -I. -Moverx -MData::Dumper -e '$a = overx->new(1,'a'); print Dumper [$a, scalar(($a * $a) * $a)]' While the following also fails: perl -I. -Moverx -MData::Dumper -e '$a = overx->new(1,'a'); print Dumper [$a, scalar(($a * $a) x $a)]' I can reproduce the bug also in 5.8.8. Perl Info
|
From ambrus@math.bme.huOn Thu May 08 07:54:20 2014, salva wrote:
Could this be because the x operator in that case is parsed as list repetition, and only string repetition can be overloaded? |
The RT System itself - Status changed from 'new' to 'open' |
From @salva----- Original Message -----
No, the expression is wrapped by a "scalar" call. In any case, the real issue is that the return value from the first |
From @salvaThe issue is caused by a 'pushmark' OP being prepended to the left-hand tree of the 'x' binary operator by the parser when the left expression is inside parenthesis. When 'x' is not overloaded the code in pp_repeat undoes the pushmark and places the result on the parent frame, but when the operation is overloaded, the tryAMAGICbin_MG macro call just returns without removing the extra frame. |
From [Unknown Contact. See original ticket]The issue is caused by a 'pushmark' OP being prepended to the left-hand tree of the 'x' binary operator by the parser when the left expression is inside parenthesis. When 'x' is not overloaded the code in pp_repeat undoes the pushmark and places the result on the parent frame, but when the operation is overloaded, the tryAMAGICbin_MG macro call just returns without removing the extra frame. |
From @iabynOn Sun, May 11, 2014 at 11:30:44AM +0200, Salvador Fandiño wrote:
In the 'x' case, an extra pushmark is happening after the '[ $a, ', Whether the pushmark is extraneous, or whether its the fault of something Anyway, I haven't really got time to look any further into this yet, as it -- |
From @cpansproutOn Mon May 12 04:17:13 2014, salva wrote:
There were two stack bugs in pp_repeat, so I fixed them both in 3a100da. Then I added an optimisation in 82e4f30 that sidesteps the issue most of the time. -- Father Chrysostomos |
@cpansprout - Status changed from 'open' to 'pending release' |
From @khwilliamsonThanks for submitting this ticket The issue should be resolved with the release today of Perl v5.22. If you find that the problem persists, feel free to reopen this ticket -- |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#121827 (status was 'resolved')
Searchable as RT121827$
The text was updated successfully, but these errors were encountered: