summaryrefslogtreecommitdiff
path: root/crates/typst-eval/src/import.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2025-02-06 22:10:43 +0100
committerGitHub <noreply@github.com>2025-02-06 21:10:43 +0000
commite4f8e57c534db8a31d51e0342c46b913a7e22422 (patch)
treeb9fefb621c2c96d0dea52ed245b7965da9c20773 /crates/typst-eval/src/import.rs
parenta1c73b41b862eb95f609f18ee99bdb6da039f478 (diff)
Fix unnecessary import rename warning (#5828)
Diffstat (limited to 'crates/typst-eval/src/import.rs')
-rw-r--r--crates/typst-eval/src/import.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/crates/typst-eval/src/import.rs b/crates/typst-eval/src/import.rs
index 27b06af4..1b164148 100644
--- a/crates/typst-eval/src/import.rs
+++ b/crates/typst-eval/src/import.rs
@@ -44,11 +44,10 @@ impl Eval for ast::ModuleImport<'_> {
}
// If there is a rename, import the source itself under that name.
- let bare_name = self.bare_name();
let new_name = self.new_name();
if let Some(new_name) = new_name {
- if let Ok(source_name) = &bare_name {
- if source_name == new_name.as_str() {
+ if let ast::Expr::Ident(ident) = self.source() {
+ if ident.as_str() == new_name.as_str() {
// Warn on `import x as x`
vm.engine.sink.warn(warning!(
new_name.span(),
@@ -57,6 +56,7 @@ impl Eval for ast::ModuleImport<'_> {
}
}
+ // Define renamed module on the scope.
vm.define(new_name, source.clone());
}