Check cyclic-import when importing package (#4737)

This commit is contained in:
Yip Coekjan 2024-08-12 16:16:56 +08:00 committed by GitHub
parent 324c937dcd
commit 3dbaf3a4ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -182,6 +182,12 @@ fn import_package(vm: &mut Vm, spec: PackageSpec, span: Span) -> SourceResult<Mo
// Evaluate the entry point. // Evaluate the entry point.
let entrypoint_id = manifest_id.join(&manifest.package.entrypoint); let entrypoint_id = manifest_id.join(&manifest.package.entrypoint);
let source = vm.world().source(entrypoint_id).at(span)?; 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; let point = || Tracepoint::Import;
Ok(eval( Ok(eval(
vm.world(), vm.world(),