## Miscellaneous

### A very interesting bug.

by joel robbin -
Number of replies: 1
the following pg code produced the following responses.
The first 5 are as expected (though I wish the 2nd response was "Can't raise a negative number to a noninteger power")
But what happened with the 6th?

...
$randomVars = 1;$a = 4;
$b = 2;$rVar='x';

if ($randomVars) {$rVar = list_random('x','y','s','t');
}

sub list_random {
my(@li) = @_;
return $li[random(1,scalar(@li))-1]; } .... ANS(List("-($b**(1/3)) - $a")->cmp); …. -2^(1/3) -4 : "The above answer is correct" (-2)^(1/3)-4 : "Can't raise a negative number to a power" y,-2^(1/3)-4 : "Variable 'y' is not defined in this context" y,(-2)^(1/3)-4 : "Variable 'y' is not defined in this context" x,-2^(1/3)-4 : "Your first value isn't a number (it looks like a formula that returns a number) x,(-2)^(1/3)-4 : The following warning: Warning messages Error in Translator.pm::process_answers: Answer AnSwEr1: |x,(-2)^(1/3)-4| 'HASH' is not defined in this context; see position 1 of formula at line 562 of [PG]/lib/AnswerHash.pm Died within AnswerEvaluator::evaluate called at line 1 of (eval 2713) Error in Translator.pm::process_answers: Answer AnSwEr1: Answer evaluators must return a hash or an AnswerHash type, not type || at /opt/webwork/pg/lib/WeBWorK/PG/Translator.pm line 1174 Use of uninitialized value$answerScore in numeric ge (>=) at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 249.
Use of uninitialized value $studentAnswer in pattern match (m//) at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 250. Use of uninitialized value$answerScore in numeric ge (>=) at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 250.
Use of uninitialized value $answerScore in numeric ge (>=) at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 251. Use of uninitialized value$answerScore in numeric gt (>) at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 251.
Use of uninitialized value \$answerScore in numeric gt (>) at /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 254.
In reply to joel robbin

### Re: A very interesting bug.

by Davide Cervone -
This was a bug in the List MathObject answer checker. It turns out that in the case where an entry in the list is constant and produces an error when computed (like the illegal power), the error was not properly reported. I have fixed the problem, and you can get the patch by updating your copy of pg/lib/Value/AnswerChecker.pm to the current HEAD version.

I've also changed the error message you complained about. It occurs in three different files, so you need to update pg/lib/Parser/BOP/power.pm, pg/lib/Value/Real.pm, and pg/macros/contextFraction.pl to get that update.

Thanks for reporting the error.

Davide