IIIM-IS / AERA

Other
12 stars 4 forks source link

Fix bug in CounterEvidence call to MatchStructure #261

Closed jefft0 closed 1 year ago

jefft0 commented 1 year ago

Background: The method MatchStructure has a parameter lhs_base_index which is passed on to the call to Match which scans the structure by incrementing lhs_index. If Match comes across an I_PTR, then it recursively calls MatchStructure where the lhs_base_index is the position of the new structure, and where 0 is again passed for lhs_index.

MatchStructure is also called from CounterEvidence, but it is called incorrectly. It correctly uses lhs_atom.asIndex() as the position of the structure, but it should not pass MK_VAL_VALUE because MatchStructure adds the two together to get the wrong code position. This is a bug that can cause an out-of-bounds error which we have seen sometimes. (It doesn't occur often because it only happens when comparing mk.val where the value is a structure, like (mk.val h holding [s]) . If the value is a float then this part of the code isn't used.)

This pull request fixes CounterEvidence to call MatchStructure in the same way that Match does, as described above. This fixes the out-of-bounds error.