summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYip Coekjan <69834864+Coekjan@users.noreply.github.com>2024-08-12 16:16:56 +0800
committerGitHub <noreply@github.com>2024-08-12 08:16:56 +0000
commit3dbaf3a4ca3437489a8c08c1d459eb20d5f7466c (patch)
treed09f92b018b2b1d70e1b3e3392d5e1264dea7a79
parent324c937dcd88f08b65280f1a3749df840e51a588 (diff)
Check cyclic-import when importing package (#4737)
-rw-r--r--crates/typst/src/eval/import.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/crates/typst/src/eval/import.rs b/crates/typst/src/eval/import.rs
index 68187a96..d02938cc 100644
--- a/crates/typst/src/eval/import.rs
+++ b/crates/typst/src/eval/import.rs
@@ -182,6 +182,12 @@ fn import_package(vm: &mut Vm, spec: PackageSpec, span: Span) -> SourceResult<Mo
// Evaluate the entry point.
let entrypoint_id = manifest_id.join(&manifest.package.entrypoint);
let source = vm.world().source(entrypoint_id).at(span)?;
+
+ // Prevent cyclic importing.
+ if vm.engine.route.contains(source.id()) {
+ bail!(span, "cyclic import");
+ }
+
let point = || Tracepoint::Import;
Ok(eval(
vm.world(),