Subject: | Overloaded operators should return new object instance |
Date: | Wed, 25 Feb 2015 23:43:45 +0300 |
To: | bug-SQL-Object [...] rt.cpan.org |
From: | Vyacheslav Pechenin <spechenin [...] gmail.com> |
$A = sql_obj("SQL1")
$B = sql_obj("SQL2")
Let us look at the logic of overloaded operator "+"
$C = $A + $B
The current module implementation makes changes to $A and then returns
reference to $A as a result.
So the result is:
$A->as_sql() eq 'SQL1 AND SQL2'; # $A is changed!
$B->as_sql() eq 'SQL2'
$C->as_sql() eq 'SQL1 AND SQL2'
$A == $C; # same address in memory
This is incorrect and in no way acceptable behaviour.