diff options
| author | Yip Coekjan <69834864+Coekjan@users.noreply.github.com> | 2024-08-12 16:16:56 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-12 08:16:56 +0000 |
| commit | 3dbaf3a4ca3437489a8c08c1d459eb20d5f7466c (patch) | |
| tree | d09f92b018b2b1d70e1b3e3392d5e1264dea7a79 | |
| parent | 324c937dcd88f08b65280f1a3749df840e51a588 (diff) | |
Check cyclic-import when importing package (#4737)
| -rw-r--r-- | crates/typst/src/eval/import.rs | 6 |
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(), |
