Skip to content

Commit

Permalink
pat: fix source pos
Browse files Browse the repository at this point in the history
Co-authored-by: Hoshino Tented <[email protected]>
  • Loading branch information
ice1000 and HoshinoTented committed Jan 4, 2025
1 parent ef7d894 commit e160945
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions base/src/main/java/org/aya/tyck/pat/PatternTycker.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public record TyckResult(

yield new Pat.Bind(bind, type);
}
case Pattern.CalmFace.INSTANCE -> doGeneratePattern(type, Constants.ANONYMOUS_PREFIX);
case Pattern.CalmFace.INSTANCE -> doGeneratePattern(type, Constants.ANONYMOUS_PREFIX, pattern.sourcePos());
case Pattern.Number(var number) -> {
var ty = whnf(type);
if (ty instanceof DataCall dataCall) {
Expand Down Expand Up @@ -369,12 +369,11 @@ private class Closer implements AutoCloseable {
}
}

private @NotNull Pat doGeneratePattern(@NotNull Term type, @NotNull String name) {
private @NotNull Pat doGeneratePattern(@NotNull Term type, @NotNull String name, @NotNull SourcePos pos) {
var freshVar = nameGen.bindName(name);
if (exprTycker.whnf(type) instanceof DataCall dataCall) {
// this pattern would be a Con, it can be inferred
// TODO: I NEED A SOURCE POS!!
return new Pat.Meta(MutableValue.create(), freshVar.name(), dataCall, SourcePos.NONE);
return new Pat.Meta(MutableValue.create(), freshVar.name(), dataCall, pos);
} else {
// If the type is not a DataCall, then the only available pattern is Pat.Bind
exprTycker.localCtx().put(freshVar, type);
Expand All @@ -389,7 +388,8 @@ private class Closer implements AutoCloseable {
*/
private @NotNull Pat generatePattern() {
try (var _ = instCurrentParam()) {
var pat = doGeneratePattern(currentParam.type(), currentParam.name());
// TODO: I NEED A SOURCE POS!!
var pat = doGeneratePattern(currentParam.type(), currentParam.name(), SourcePos.NONE);
addArgSubst(pat, currentParam.type());
return pat;
}
Expand Down

0 comments on commit e160945

Please sign in to comment.