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
$tied_hash{overloaded_object} += 3; fails #11153
Comments
From @ikegamiHi, Given a tied hash that contains a value which is an object with overloads, $tied_hash{overloaded_object} += 3; The overloaded '+=' isn't getting called. The following works fine: $tied_hash{overloaded_object} = $tied_hash{overloaded_object} + 3; Tested with v5.12.2 and a recent blead (v5.13.9-284-g76cc22e). Test case and output below. - Eric Brine ----- BEGIN CODE ----- use strict; { use overload sub append { use Test::More tests => 3; use Tie::Hash qw( ); { # Works for "+" instead of "+=". eval { $hash{'test'} = $hash{'test'} + 3; 1 } is(3, $hash{'test'}[0], '+, tied hash'); { # Works for untied hash, so it's not a problem with the overloaded object. eval { $hash{'test'} += 3; 1 } is(3, $hash{'test'}[0], '+=, normal hash'); { eval { $hash{'test'} += 3; 1 } is(3, $hash{'test'}[0], '+=, tied hash'); ----- BEGIN OUTPUT ----- |
From @iabynOn Wed, Feb 23, 2011 at 01:09:06PM -0800, Eric Brine wrote:
This was fixed in a recent blead. Under blead, you get instead: ok 1 - +, tied hash because with a tie, it can't determine whether its safe to skip using the '=' => sub { bless [ @{$_[0]} ], 'Test' }, makes all three tests pass. -- |
The RT System itself - Status changed from 'new' to 'open' |
@iabyn - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#84786 (status was 'resolved')
Searchable as RT84786$
The text was updated successfully, but these errors were encountered: