Skip to content

Commit

Permalink
import: 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 e160945 commit df382d5
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2024 Tesla (Yinsen) Zhang.
// Copyright (c) 2020-2025 Tesla (Yinsen) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.resolve.visitor;

Expand Down Expand Up @@ -64,7 +64,7 @@ public ImmutableSeq<ResolvingStmt> resolveStmt(@NotNull ImmutableSeq<Stmt> stmts
context.reportAndThrow(new NameProblem.ModNotFoundError(modulePath, cmd.sourcePos()));
var mod = success.thisModule();
var as = cmd.asName();
var importedName = as != null ? ModuleName.This.resolve(as) : modulePath.asName();
var importedName = as != null ? ModuleName.This.resolve(as.data()) : modulePath.asName();
context.importModuleContext(importedName, mod, cmd.accessibility(), cmd.sourcePos());
var importInfo = new ResolveInfo.ImportInfo(success, cmd.accessibility() == Stmt.Accessibility.Public);
resolveInfo.imports().put(importedName, importInfo);
Expand Down
2 changes: 1 addition & 1 deletion note/clause-tyck.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
`PatternTycker` 负责找到用户给定的 pattern 所对应的 parameter,并且在遇到问题时报错,
如过多隐式 pattern 或过少的 pattern。

尽管我们一开始就对函数签名进行 pusheen,对于 PatternTycker 来说,它需要知道哪些 parameter 是必须有 pattern 而哪些不必须。因此,在 pattern
尽管我们一开始就对函数签名进行 pusheen,但对于 PatternTycker 来说,它需要知道哪些 parameter 是必须有 pattern 而哪些不必须。因此,在 pattern

## After Pattern Typecheck (checkLhs)

Expand Down
4 changes: 2 additions & 2 deletions producer/src/main/java/org/aya/producer/AyaProducer.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2024 Tesla (Yinsen) Zhang.
// Copyright (c) 2020-2025 Tesla (Yinsen) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.producer;

Expand Down Expand Up @@ -120,7 +120,7 @@ public record AyaProducer(
return new Command.Import(
sourcePosOf(importMod),
modulePath(importMod),
asId == null ? null : weakId(asId).data(),
asId == null ? null : weakId(asId),
acc == null ? Stmt.Accessibility.Private : Stmt.Accessibility.Public
);
}
Expand Down
4 changes: 2 additions & 2 deletions syntax/src/main/java/org/aya/prettier/ConcretePrettier.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2024 Tesla (Yinsen) Zhang.
// Copyright (c) 2020-2025 Tesla (Yinsen) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.prettier;

Expand Down Expand Up @@ -294,7 +294,7 @@ private Doc visitAccess(@NotNull Accessibility acc, @Nullable Accessibility theD
var prelude = MutableList.of(KW_IMPORT, Doc.symbol(cmd.path().toString()));
if (cmd.asName() != null) {
prelude.append(KW_AS);
prelude.append(Doc.plain(cmd.asName()));
prelude.append(Doc.plain(cmd.asName().data()));

Check warning on line 297 in syntax/src/main/java/org/aya/prettier/ConcretePrettier.java

View check run for this annotation

Codecov / codecov/patch

syntax/src/main/java/org/aya/prettier/ConcretePrettier.java#L297

Added line #L297 was not covered by tests
}
yield Doc.sep(prelude);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2024 Tesla (Yinsen) Zhang.
// Copyright (c) 2020-2025 Tesla (Yinsen) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.syntax.concrete.stmt;

Expand All @@ -8,6 +8,7 @@
import org.aya.syntax.ref.ModulePath;
import org.aya.util.error.PosedUnaryOperator;
import org.aya.util.error.SourcePos;
import org.aya.util.error.WithPos;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -17,7 +18,7 @@ public sealed interface Command extends Stmt {
record Import(
@Override @NotNull SourcePos sourcePos,
@NotNull ModulePath path,
@Nullable String asName,
@Nullable WithPos<String> asName,
@Override @NotNull Accessibility accessibility
) implements Command { }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2024 Tesla (Yinsen) Zhang.
// Copyright (c) 2020-2025 Tesla (Yinsen) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.syntax.concrete.stmt;

Expand Down Expand Up @@ -77,10 +77,9 @@ private void visitVars(@NotNull Stmt stmt) {
case Generalize g -> g.variables.forEach(v -> visitVarDecl(v.sourcePos, v, noType));
case Command.Module m -> visitModuleDecl(m.sourcePos(), ModuleName.of(m.name()));
case Command.Import i -> {
var isAlsoDef = i.asName() == null;
visitModuleRef(i.sourcePos(), i.path());
if (!isAlsoDef) {
visitModuleDecl(i.sourcePos(), ModuleName.of(i.asName()));
if (i.asName() instanceof WithPos(var pos, var asName)) {
visitModuleDecl(pos, ModuleName.of(asName));
} else {
// TODO: visitModuleDecl on the last element of i.path
}
Expand Down

0 comments on commit df382d5

Please sign in to comment.