WeBWorK Main Forum

niceTables: Use of uninitialized value in numeric eq

niceTables: Use of uninitialized value in numeric eq

by Andrew Dabrowski -
Number of replies: 2
Here I am again.

I can't figure out why this causes warnings.

DOCUMENT(); 
loadMacros(
 "PGstandard.pl",
 "MathObjects.pl",
 "PGML.pl",
 "niceTables.pl"
);
TEXT(beginproblem);
Context("Numeric");
$answerlist = [ 1, 2 ];
$payoffmatlatex = DataTable(
 [ [ ans_rule(1), ans_rule(1) ]
 ],
 align => 'cc' );
BEGIN_PGML
 
[@ $payoffmatlatex @]*
 
 END_PGML
 
 ##############################
 
 $showPartialCorrectAnswers = 0;
map { ANS( Compute($_)->cmp() ) } @$answerlist;
ENDDOCUMENT(); 


The warnings:

WeBWorK has encountered warnings while processing your request. If this occured when viewing a problem, it was likely caused by an error or ambiguity in that problem. Otherwise, it may indicate a problem with the WeBWorK system itself. If you are a student, report these warnings to your professor to have them corrected. If you are a professor, please consult the warning output below for more information.

Warning messages

  • Use of uninitialized value in numeric eq (==) at line 249 of [PG]/macros/niceTables.pl
  • Use of uninitialized value in numeric eq (==) at line 251 of [PG]/macros/niceTables.pl
  • Use of uninitialized value in numeric eq (==) at line 252 of [PG]/macros/niceTables.pl
  • Use of uninitialized value in numeric eq (==) at line 253 of [PG]/macros/niceTables.pl
  • Use of uninitialized value in numeric eq (==) at line 249 of [PG]/macros/niceTables.pl
  • Use of uninitialized value in numeric eq (==) at line 251 of [PG]/macros/niceTables.pl
  • Use of uninitialized value in numeric eq (==) at line 252 of [PG]/macros/niceTables.pl
  • Use of uninitialized value in numeric eq (==) at line 253 of [PG]/macros/niceTables.pl


It seems that niceTables is expecting style info like i=>1 or b=>1, but surely it will substitute default values if those options are missing?
In reply to Andrew Dabrowski

Re: niceTables: Use of uninitialized value in numeric eq

by Alex Jordan -
Hmm, this used to work. These comparisons formerly evaluated to false under these conditions, but something has changed and now we get the error that one side is undefined. I'm out of town at the moment, but I should be able to patch this and submit a pull request in the coming week. I'll post here once I have done that.

For now, if your problem is urgent, then although it is tedious, the following works:


$payoffmatlatex = DataTable([[ [ans_rule(1),b=>0,i=>0,m=>0,noencase=>1,cellcss=>''], [ans_rule(1),b=>0,i=>0,m=>0,noencase=>1,cellcss=>'']
]],
align => 'cc' );



Perhaps this was just part of an MWE, but if this were the extent of the table, I would use LayoutTable instead of DataTable.

In reply to Andrew Dabrowski

Re: niceTables: Use of uninitialized value in numeric eq

by Alex Jordan -
I submitted a pull request that fixes this at https://github.com/openwebwork/pg/pull/223.

Now all of the cell options are initialized. Warnings like this would have been thrown out all over the place when I first wrote this macro, so I'm guessing maybe something changed with how Perl behaves on those comparisons. Or how WeBWorK responds to getting such warnings from Perl.

With the patch, both your MWE and a big file I have for testing the features of niceTable.pl are working as expected.

If you would like this sooner than the normal workflow provides (approval of the pull request into the develop branch, followed by the next release of pg) you can just copy that niceTables.pl from my GitHub account by following the pull request.