Commit 8db04369 authored by Moritz Dieing's avatar Moritz Dieing
Browse files

Actually fix exception thrown by last example

parent 49adac2a
...@@ -193,13 +193,16 @@ public class ExplanationCreator implements StepVisitor { ...@@ -193,13 +193,16 @@ public class ExplanationCreator implements StepVisitor {
explanationTexts.add(createLatexLetStep(letD, variable, innerTerm, variableDefinition)); explanationTexts.add(createLatexLetStep(letD, variable, innerTerm, variableDefinition));
letD.getTypeInferer().getFirstInferenceStep().accept(this); letD.getTypeInferer().getFirstInferenceStep().accept(this);
ExplanationCreatorUnification unification = // skip creation of unification texts if nested let produced an error
new ExplanationCreatorUnification(letD.getTypeInferer(), locale, provider, MODE, letCounter, true, if (!errorOccurred) {
Optional.of(variable)); ExplanationCreatorUnification unification =
explanationTexts.addAll(unification.getUnificationsTexts().getLeft()); new ExplanationCreatorUnification(letD.getTypeInferer(), locale, provider, MODE, letCounter, true,
errorOccurred = unification.getUnificationsTexts().getRight(); Optional.of(variable));
letCounter--; explanationTexts.addAll(unification.getUnificationsTexts().getLeft());
errorOccurred = unification.getUnificationsTexts().getRight();
letCounter--;
}
if (!errorOccurred) { if (!errorOccurred) {
letD.getPremise().accept(this); letD.getPremise().accept(this);
} }
......
...@@ -105,8 +105,6 @@ public class ExplanationCreatorUnification { ...@@ -105,8 +105,6 @@ public class ExplanationCreatorUnification {
if (isLetUnification) { if (isLetUnification) {
createLetUnficiationFinish(); createLetUnficiationFinish();
} }
} else if (isLetUnification) {
unificationTexts.remove(unificationTexts.size() - 1);
} }
} }
...@@ -159,7 +157,6 @@ public class ExplanationCreatorUnification { ...@@ -159,7 +157,6 @@ public class ExplanationCreatorUnification {
return provider.getTranslation(textKey, locale); return provider.getTranslation(textKey, locale);
} }
// WARNING: call toLatex() before to get proper latex code
private String letCounterToLatex(String setName) { private String letCounterToLatex(String setName) {
switch (letCounter) { switch (letCounter) {
case 0: case 0:
...@@ -187,13 +184,8 @@ public class ExplanationCreatorUnification { ...@@ -187,13 +184,8 @@ public class ExplanationCreatorUnification {
} }
private void createUnficationTexts() { private void createUnficationTexts() {
List<UnificationStep> unificationSteps; List<UnificationStep> unificationSteps = typeInferer.getUnificationSteps()
if (typeInferer.getUnificationSteps().isPresent()) { .orElseThrow(IllegalStateException::new);
unificationSteps = typeInferer.getUnificationSteps().get();
} else {
errorOccurred = true;
return;
}
// skip first step since the substitutions list is still empty (unification introduction is shown) // skip first step since the substitutions list is still empty (unification introduction is shown)
for (int stepNum = 1; stepNum < unificationSteps.size(); stepNum++) { for (int stepNum = 1; stepNum < unificationSteps.size(); stepNum++) {
...@@ -258,10 +250,8 @@ public class ExplanationCreatorUnification { ...@@ -258,10 +250,8 @@ public class ExplanationCreatorUnification {
private void createErrorText(UnificationError errorType) { private void createErrorText(UnificationError errorType) {
if (errorType == UnificationError.INFINITE_TYPE) { if (errorType == UnificationError.INFINITE_TYPE) {
unificationTexts.add(getDefaultTextLatex(KEY_PREFIX + "infiniteType")); unificationTexts.add(getDefaultTextLatex(KEY_PREFIX + "infiniteType"));
unificationTexts.add(getDefaultTextLatex(KEY_PREFIX + "infiniteType"));
} else if (errorType == UnificationError.DIFFERENT_TYPES) { } else if (errorType == UnificationError.DIFFERENT_TYPES) {
unificationTexts.add(getDefaultTextLatex(KEY_PREFIX + "differentTypes")); unificationTexts.add(getDefaultTextLatex(KEY_PREFIX + "differentTypes"));
unificationTexts.add(getDefaultTextLatex(KEY_PREFIX + "differentTypes"));
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment