From 2ce0092000f545d5b1b7dcddcb9299ff443f3d4f Mon Sep 17 00:00:00 2001 From: Pieter Olivier Date: Tue, 19 Nov 2024 12:12:41 +0100 Subject: [PATCH] Fixed the case where one of the alternative of an ambiguity is an empty error --- .../rascalmpl/library/util/ErrorRecovery.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/org/rascalmpl/library/util/ErrorRecovery.java b/src/org/rascalmpl/library/util/ErrorRecovery.java index d117a59d717..8282d3dec4a 100644 --- a/src/org/rascalmpl/library/util/ErrorRecovery.java +++ b/src/org/rascalmpl/library/util/ErrorRecovery.java @@ -31,10 +31,12 @@ public ErrorRecovery(IRascalValueFactory rascalValues) { private static class ScoredTree { public final IConstructor tree; public final int score; + public final boolean hasErrors; - public ScoredTree(IConstructor tree, int score) { + public ScoredTree(IConstructor tree, int score, boolean hasErrors) { this.tree = tree; this.score = score; + this.hasErrors = hasErrors; } } @@ -60,8 +62,8 @@ private ScoredTree disambiguate(IConstructor tree, boolean allowAmbiguity, Map disambiguatedAlt.score) { + errorAltWithBestScore = disambiguatedAlt; + } + } else { // Non-error tree if (alternativesWithoutErrors == null) { alternativesWithoutErrors = rascalValues.setWriter(); } alternativesWithoutErrors.insert(disambiguatedAlt.tree); - } else { - // Only keep the best of the error trees - if (errorAltWithBestScore == null || errorAltWithBestScore.score > disambiguatedAlt.score) { - errorAltWithBestScore = disambiguatedAlt; - } } } @@ -166,7 +170,7 @@ private ScoredTree disambiguateAmb(ITree amb, boolean allowAmbiguity, Map