From 9a4f69f52e34ea34f1bf69c45ff1bcd22cf3e957 Mon Sep 17 00:00:00 2001 From: Jose Mendoza <56417208+StunxFS@users.noreply.github.com> Date: Wed, 27 Dec 2023 18:01:20 +0000 Subject: [PATCH] self-host: fix bug --- lib/rivet/src/builder/mod.ri | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/rivet/src/builder/mod.ri b/lib/rivet/src/builder/mod.ri index 1ad421c6a..16ac5e08e 100644 --- a/lib/rivet/src/builder/mod.ri +++ b/lib/rivet/src/builder/mod.ri @@ -340,14 +340,15 @@ pub struct Builder { } for d in pf.decls { if d is .Import(import_decl) { - if !import_decl.info.found { - continue; // module not found + if import_decl.subimports.len > 0 { + for subimport in import_decl.subimports { + if dep := import_graph_mod(&subimport, pf) { + deps.push(dep); + } + } + } else if dep := import_graph_mod(&import_decl, pf) { + deps.push(dep); } - if import_decl.info.full_name == pf.mod.name { - report.error("import cycle detected", import_decl.pos); - continue; - } - deps.push(import_decl.info.full_name); } } g.add(pf.mod.name, deps); @@ -355,6 +356,17 @@ pub struct Builder { return g; } + func import_graph_mod(import_decl: &ast.ImportDecl, pf: ast.SourceFile) -> ?string { + if !import_decl.info.found { + return none; // module not found + } + if import_decl.info.full_name == pf.mod.name { + report.error("import cycle detected", import_decl.pos); + return none; + } + return import_decl.info.full_name; + } + func vlog(&self, msg: string, args: ...traits.Stringable) { if self.env.prefs.is_verbose { console.writeln(utils.bold(utils.green("[rivet-log] ")).concat(msg), args);