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