Skip to content

Commit

Permalink
self-host: fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
StunxFS committed Dec 27, 2023
1 parent 6ac11b9 commit 9a4f69f
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions lib/rivet/src/builder/mod.ri
Original file line number Diff line number Diff line change
Expand Up @@ -340,21 +340,33 @@ 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);
}
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);
Expand Down

0 comments on commit 9a4f69f

Please sign in to comment.