C++: fix bug in PredictionContext::mergeArrays

In the orignal PredictionContext::mergeArrays there was a bug on Line 281 where the logic differs from java: It currently is:
bool both$ = payload == EMPTY_RETURN_STATE && a_parent && b_parent;
and should instead match java as:
bool both$ = payload == EMPTY_RETURN_STATE && !a_parent && !b_parent;
This commit is contained in:
WalterCouto 2018-12-20 10:07:59 -05:00
parent 70d9ddcd0a
commit 27c8eb5c6a
2 changed files with 3 additions and 2 deletions

View File

@ -210,3 +210,4 @@ YYYY/MM/DD, github id, Full name, email
2018/11/14, nxtstep, Adriaan (Arjan) Duz, codewithadriaan[et]gmail[dot]com
2018/11/15, amykyta3, Alex Mykyta, amykyta3@users.noreply.github.com
2018/11/29, hannemann-tamas, Ralf Hannemann-Tamas, ralf.ht@gmail.com
2018/12/20, WalterCouto, Walter Couto, WalterCouto@users.noreply.github.com

View File

@ -278,7 +278,7 @@ Ref<PredictionContext> PredictionContext::mergeArrays(const Ref<ArrayPredictionC
// same payload (stack tops are equal), must yield merged singleton
size_t payload = a->returnStates[i];
// $+$ = $
bool both$ = payload == EMPTY_RETURN_STATE && a_parent && b_parent;
bool both$ = payload == EMPTY_RETURN_STATE && !a_parent && !b_parent;
bool ax_ax = (a_parent && b_parent) && *a_parent == *b_parent; // ax+ax -> ax
if (both$ || ax_ax) {
mergedParents[k] = a_parent; // choose left