From 27c8eb5c6a673abf77310a7ceffd979d5d31d33a Mon Sep 17 00:00:00 2001 From: WalterCouto Date: Thu, 20 Dec 2018 10:07:59 -0500 Subject: [PATCH] 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; --- contributors.txt | 3 ++- runtime/Cpp/runtime/src/atn/PredictionContext.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/contributors.txt b/contributors.txt index 230e494f2..f48052823 100644 --- a/contributors.txt +++ b/contributors.txt @@ -209,4 +209,5 @@ YYYY/MM/DD, github id, Full name, email 2018/11/12, vinoski, Steve Vinoski, vinoski@ieee.org 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 \ No newline at end of file +2018/11/29, hannemann-tamas, Ralf Hannemann-Tamas, ralf.ht@gmail.com +2018/12/20, WalterCouto, Walter Couto, WalterCouto@users.noreply.github.com \ No newline at end of file diff --git a/runtime/Cpp/runtime/src/atn/PredictionContext.cpp b/runtime/Cpp/runtime/src/atn/PredictionContext.cpp index 95c54a0d0..597e083a6 100755 --- a/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +++ b/runtime/Cpp/runtime/src/atn/PredictionContext.cpp @@ -278,7 +278,7 @@ Ref PredictionContext::mergeArrays(const RefreturnStates[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