diff --git a/src/analyzer.rs b/src/analyzer.rs index f4f950bb58..798cde9c73 100644 --- a/src/analyzer.rs +++ b/src/analyzer.rs @@ -84,9 +84,9 @@ impl<'src> Analyzer<'src> { assignments.push(assignment); } Item::Comment(_) => (), - Item::Import { absolute, .. } => { - if let Some(absolute) = absolute { - stack.push(asts.get(absolute).unwrap()); + Item::Import { absolute_paths, .. } => { + for p in absolute_paths { + stack.push(asts.get(p).unwrap()); } } Item::Module { diff --git a/src/compiler.rs b/src/compiler.rs index 1a555ebabb..b46e67f3b6 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -64,7 +64,7 @@ impl Compiler { } Item::Import { relative, - absolute, + absolute_paths, optional, path, } => { @@ -75,6 +75,8 @@ impl Compiler { .join(Self::expand_tilde(&relative.cooked)?) .lexiclean(); + println!("IMPORT: {}", import.display()); + if import.is_file() { if current.file_path.contains(&import) { return Err(Error::CircularImport { @@ -82,7 +84,8 @@ impl Compiler { import, }); } - *absolute = Some(import.clone()); + //*absolute = Some(import.clone()); + *absolute_paths = vec![import.clone()]; stack.push(current.import(import, path.offset)); } else if !*optional { return Err(Error::MissingImportFile { path: *path }); diff --git a/src/item.rs b/src/item.rs index 08d723fe70..23cbb0176e 100644 --- a/src/item.rs +++ b/src/item.rs @@ -7,7 +7,7 @@ pub(crate) enum Item<'src> { Assignment(Assignment<'src>), Comment(&'src str), Import { - absolute: Option, + absolute_paths: Vec, optional: bool, path: Token<'src>, relative: StringLiteral<'src>, diff --git a/src/parser.rs b/src/parser.rs index da2ff76f3f..a82f15b241 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -365,7 +365,7 @@ impl<'run, 'src> Parser<'run, 'src> { let optional = self.accepted(QuestionMark)?; let (path, relative) = self.parse_string_literal_token()?; items.push(Item::Import { - absolute: None, + absolute_paths: vec![], optional, path, relative,