Skip to content

Commit

Permalink
Fix stackoverflow in SubstExpression
Browse files Browse the repository at this point in the history
  • Loading branch information
valis committed Apr 24, 2024
1 parent a9399d9 commit a8a2cf1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions base/src/main/java/org/arend/core/expr/SubstExpression.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ public static Expression make(Expression expression, ExprSubstitution substituti
return new SubstExpression(infRefExpr, newSubst, ((SubstExpression) expression).getLevelSubstitution().subst(levelSubstitution));
}

return new SubstExpression(expression, new ExprSubstitution(substitution), levelSubstitution);
if (expression instanceof InferenceReferenceExpression infRefExpr) {
Expression expr = infRefExpr.getSubstExpression();
return expr == null ? new SubstExpression(expression, new ExprSubstitution(substitution), levelSubstitution) : expr.subst(substitution, levelSubstitution);
}

return expression.subst(substitution, levelSubstitution);
}

public Expression getExpression() {
Expand Down Expand Up @@ -81,9 +86,8 @@ public Expression getSubstExpression() {
}

public Expression eval() {
if (myExpression instanceof LetExpression) {
if (myExpression instanceof LetExpression let) {
ExprSubstitution substitution = new ExprSubstitution(mySubstitution);
LetExpression let = (LetExpression) myExpression;
if (let.isStrict()) {
for (HaveClause letClause : let.getClauses()) {
substitution.add(letClause, LetExpression.normalizeClauseExpression(letClause.getPattern(), letClause.getExpression().subst(substitution, levelSubstitution)));
Expand Down

0 comments on commit a8a2cf1

Please sign in to comment.