This is an automated email from the ASF dual-hosted git repository.

mboehm7 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/systemds.git


The following commit(s) were added to refs/heads/main by this push:
     new 21bce770ef [SYSTEMDS-614] Improve error messages for 
no-viable-alternatives
21bce770ef is described below

commit 21bce770eff2511d29425b65e4e302d329d8bdb4
Author: Matthias Boehm <[email protected]>
AuthorDate: Wed Jul 12 21:59:37 2023 +0200

    [SYSTEMDS-614] Improve error messages for no-viable-alternatives
    
    This patch fixes a slightly confusing error message, where the line
    number for no-variable-alternative exceptions shows the last line of
    the script instead of the function or variable that cannot be resolved.
---
 src/main/java/org/apache/sysds/parser/dml/CustomErrorListener.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sysds/parser/dml/CustomErrorListener.java 
b/src/main/java/org/apache/sysds/parser/dml/CustomErrorListener.java
index 619a2ac6b5..f06953c15d 100644
--- a/src/main/java/org/apache/sysds/parser/dml/CustomErrorListener.java
+++ b/src/main/java/org/apache/sysds/parser/dml/CustomErrorListener.java
@@ -368,7 +368,7 @@ public class CustomErrorListener extends BaseErrorListener {
                        int issueLineNum = parseIssue.getLine();
                        boolean displayScriptLine = false;
                        String scriptLine = null;
-                       if ((issueLineNum > 0) && (issueLineNum <= 
scriptLines.length)) {
+                       if ((issueLineNum >= 0) && (issueLineNum <= 
scriptLines.length)) {
                                displayScriptLine = true;
                                scriptLine = scriptLines[issueLineNum - 1];
                        }
@@ -391,6 +391,8 @@ public class CustomErrorListener extends BaseErrorListener {
                        }
                        sb.append("\n   ");
                        sb.append(parseIssue.getMessage());
+                       if( parseIssue.getMessage().startsWith("no viable 
alternative") )
+                               sb.append("\n   (NoViableAltException thrown at 
EOF: line "+issueLineNum+")");
                        sb.append("\n");
                }
                
sb.append("--------------------------------------------------------------");

Reply via email to