Skip to content

Commit

Permalink
merge: #1014 (Freeze holes in context)
Browse files Browse the repository at this point in the history
Fix #1013 

Thanks @dannypsnl for reporting this 🎉
  • Loading branch information
ice1000 authored Nov 15, 2023
2 parents 69b0f2d + 1206ac9 commit 4a21d50
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions base/src/main/java/org/aya/tyck/error/Goal.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import kala.collection.immutable.ImmutableSeq;
import org.aya.core.term.ErrorTerm;
import org.aya.core.term.MetaTerm;
import org.aya.core.term.Term;
import org.aya.generic.util.NormalizeMode;
import org.aya.pretty.doc.Doc;
import org.aya.ref.LocalVar;
Expand All @@ -14,11 +15,7 @@
import org.aya.util.reporter.Problem;
import org.jetbrains.annotations.NotNull;

public record Goal(
@NotNull TyckState state,
@NotNull MetaTerm hole,
@NotNull ImmutableSeq<LocalVar> scope
) implements Problem {
public record Goal(@NotNull TyckState state, @NotNull MetaTerm hole, @NotNull ImmutableSeq<LocalVar> scope) implements Problem {
@Override public @NotNull Doc describe(@NotNull PrettierOptions options) {
var meta = hole.ref();
var nullableResult = meta.info.result();
Expand All @@ -30,18 +27,18 @@ public record Goal(
Doc.par(1, Doc.parened(Doc.sep(Doc.plain("Normalized:"), result.normalize(state, NormalizeMode.NF).toDoc(options)))),
Doc.plain("Context:"),
Doc.vcat(meta.fullTelescope().map(param -> {
param = new Term.Param(param, param.type().freezeHoles(state));
var paramDoc = param.toDoc(options);
return Doc.par(1, scope.contains(param.ref()) ? paramDoc : Doc.sep(paramDoc, Doc.parened(Doc.english("not in scope"))));
})),
meta.conditions.isNotEmpty() ?
Doc.vcat(
ImmutableSeq.of(Doc.plain("To ensure confluence:"))
.concat(meta.conditions.toImmutableSeq().map(tup -> Doc.par(1, Doc.cat(
Doc.plain("Given "),
Doc.parened(tup.component1().toDoc(options)),
Doc.plain(", we should have: "),
tup.component2().toDoc(options)
)))))
meta.conditions.isNotEmpty() ? Doc.vcat(
ImmutableSeq.of(Doc.plain("To ensure confluence:"))
.concat(meta.conditions.toImmutableSeq().map(tup -> Doc.par(1, Doc.cat(
Doc.plain("Given "),
Doc.parened(tup.component1().toDoc(options)),
Doc.plain(", we should have: "),
tup.component2().freezeHoles(state).toDoc(options)
)))))
: Doc.empty()
);
var metas = state.metas();
Expand Down

0 comments on commit 4a21d50

Please sign in to comment.