From: dpvc v. a. <we...@ma...> - 2005-09-12 23:28:07
|
Log Message: ----------- Fixed an error where scalar() was used on a hash ref. Fixed a misfeature where operations on formulas could return Value objects of other classes; they should always return formulas, even when the formula is constant. Modified Files: -------------- pg/lib/Value: Formula.pm Revision Data ------------- Index: Formula.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/Formula.pm,v retrieving revision 1.36 retrieving revision 1.37 diff -Llib/Value/Formula.pm -Llib/Value/Formula.pm -u -r1.36 -r1.37 --- lib/Value/Formula.pm +++ lib/Value/Formula.pm @@ -108,7 +108,7 @@ ($l->type =~ m/Interval|Set|Union/ || $r->type =~ m/Interval|Set|Union/); $formula->{tree} = $parser->{BOP}->new($formula,$bop,$l,$r); $formula->{variables} = $formula->{tree}->getVariables; - return $formula->eval if scalar(%{$formula->{variables}}) == 0; +# return $formula->eval if $formula->{isConstant}; return $formula; } @@ -148,7 +148,7 @@ $formula->{context} = $self->{context}; $formula->{variables} = $self->{variables}; $formula->{tree} = $formula->{context}{parser}{UOP}->new($formula,'u-',$self->{tree}->copy($formula)); - return $formula->eval if scalar(%{$formula->{variables}}) == 0; +# return $formula->eval if $formula->isConstant; return $formula; } @@ -481,7 +481,10 @@ # Check if the value of a formula is constant # (could use shift->{tree}{isConstant}, but I don't trust it) # -sub isConstant {scalar(%{shift->{variables}}) == 0} +sub isConstant { + my @vars = (%{shift->{variables}}); + return scalar(@vars) == 0; +} ############################################ # |