From 340c28cc4e7ab49c5b9c9f3183d5252746e64655 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Tue, 3 Feb 2026 17:46:50 -0500 Subject: [PATCH 1/3] Broken version --- tests/projects/implicit_root_import.yaml | 14 ++++++++++++++ tests/projects/implicit_root_import/a/b/inner.rue | 5 +++++ tests/projects/implicit_root_import/main.rue | 5 +++++ tests/projects/implicit_root_import/utils.rue | 3 +++ 4 files changed, 27 insertions(+) create mode 100644 tests/projects/implicit_root_import.yaml create mode 100644 tests/projects/implicit_root_import/a/b/inner.rue create mode 100644 tests/projects/implicit_root_import/main.rue create mode 100644 tests/projects/implicit_root_import/utils.rue diff --git a/tests/projects/implicit_root_import.yaml b/tests/projects/implicit_root_import.yaml new file mode 100644 index 00000000..22d0a747 --- /dev/null +++ b/tests/projects/implicit_root_import.yaml @@ -0,0 +1,14 @@ +program: (q . "Hello, world main!") +debug_program: (a (q 2 2 (q . "world main")) (c (q 14 (concat (q . "Hello, ") 1) (q . 33)) ())) +output: '"Hello, world main!"' +runtime_cost: 20 +byte_cost: 252000 +total_cost: 252020 +tests: +- name: inner + program: (q . "Hello, world inner!") + debug_program: (a (q 2 2 (q . "world inner")) (c (q 14 (concat (q . "Hello, ") 1) (q . 33)) ())) + output: '"Hello, world inner!"' + runtime_cost: 20 + byte_cost: 264000 + total_cost: 264020 diff --git a/tests/projects/implicit_root_import/a/b/inner.rue b/tests/projects/implicit_root_import/a/b/inner.rue new file mode 100644 index 00000000..af7ff018 --- /dev/null +++ b/tests/projects/implicit_root_import/a/b/inner.rue @@ -0,0 +1,5 @@ +import utils::greet; + +test fn inner() -> String { + greet("world inner") +} diff --git a/tests/projects/implicit_root_import/main.rue b/tests/projects/implicit_root_import/main.rue new file mode 100644 index 00000000..7c22eccb --- /dev/null +++ b/tests/projects/implicit_root_import/main.rue @@ -0,0 +1,5 @@ +import utils::greet; + +fn main() -> String { + greet("world main") +} diff --git a/tests/projects/implicit_root_import/utils.rue b/tests/projects/implicit_root_import/utils.rue new file mode 100644 index 00000000..a8680619 --- /dev/null +++ b/tests/projects/implicit_root_import/utils.rue @@ -0,0 +1,3 @@ +export fn greet(name: String) -> String { + "Hello, " + name + "!" +} From 18f2d74b0a323dfae457882fc1a39346ef568812 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Tue, 3 Feb 2026 18:08:56 -0500 Subject: [PATCH 2/3] Fix implicit root import --- crates/rue-compiler/src/compile/imports.rs | 19 ++++++++++++++----- crates/rue-hir/src/import.rs | 1 + tests/projects/implicit_root_import.yaml | 17 +++-------------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/crates/rue-compiler/src/compile/imports.rs b/crates/rue-compiler/src/compile/imports.rs index bab3068b..2b85045b 100644 --- a/crates/rue-compiler/src/compile/imports.rs +++ b/crates/rue-compiler/src/compile/imports.rs @@ -40,6 +40,7 @@ fn construct_imports( exported: bool, ) -> Vec { let mut has_non_super = false; + let mut has_super = false; if let Some(segment) = segments.first() && let Some(separator) = segment.separator() @@ -59,6 +60,8 @@ fn construct_imports( } else { ctx.diagnostic(&name, DiagnosticKind::UnresolvedSuper); } + + has_super = true; } else { path.push(ctx.local_name(&name)); has_non_super = true; @@ -88,6 +91,7 @@ fn construct_imports( items: Items::Named(name), exported, declarations: Vec::new(), + has_super, })] } else if let Some(star) = last.star() { let star = ctx.local_name(&star); @@ -99,6 +103,7 @@ fn construct_imports( items: Items::All(star), exported, declarations: Vec::new(), + has_super, })] } else if let items = last.items().collect::>() && !items.is_empty() @@ -124,7 +129,7 @@ fn construct_imports( #[derive(Debug, Default)] pub struct ImportCache { - scopes: HashMap, (ScopeId, SymbolId)>, + scopes: HashMap<(ScopeId, Vec), (ScopeId, SymbolId)>, unused_imports: IndexMap>, glob_import_counts: IndexMap, } @@ -214,6 +219,7 @@ fn resolve_import( missing_imports: &mut IndexMap>, ) -> bool { let import = ctx.import(import_id).clone(); + let has_super = import.has_super; let source = import.source.clone(); let mut base = None; @@ -227,7 +233,7 @@ fn resolve_import( .map(|t| t.text().to_string()) .collect::>(); - if let Some(cached) = cache.scopes.get(&subpath) { + if let Some(cached) = cache.scopes.get(&(import_scope, subpath.clone())) { base = Some(cached.0); path_so_far = subpath; @@ -300,9 +306,12 @@ fn resolve_import( base = Some(module.scope); path_so_far.push(name.text().to_string()); - cache - .scopes - .insert(path_so_far.clone(), (module.scope, symbol)); + + if !has_super { + cache + .scopes + .insert((import_scope, path_so_far.clone()), (module.scope, symbol)); + } } let mut updated = false; diff --git a/crates/rue-hir/src/import.rs b/crates/rue-hir/src/import.rs index 0b2844fa..5b546515 100644 --- a/crates/rue-hir/src/import.rs +++ b/crates/rue-hir/src/import.rs @@ -13,6 +13,7 @@ pub struct Import { pub items: Items, pub exported: bool, pub declarations: Vec<(String, Declaration)>, + pub has_super: bool, } #[derive(Debug, Clone)] diff --git a/tests/projects/implicit_root_import.yaml b/tests/projects/implicit_root_import.yaml index 22d0a747..1354b77c 100644 --- a/tests/projects/implicit_root_import.yaml +++ b/tests/projects/implicit_root_import.yaml @@ -1,14 +1,3 @@ -program: (q . "Hello, world main!") -debug_program: (a (q 2 2 (q . "world main")) (c (q 14 (concat (q . "Hello, ") 1) (q . 33)) ())) -output: '"Hello, world main!"' -runtime_cost: 20 -byte_cost: 252000 -total_cost: 252020 -tests: -- name: inner - program: (q . "Hello, world inner!") - debug_program: (a (q 2 2 (q . "world inner")) (c (q 14 (concat (q . "Hello, ") 1) (q . 33)) ())) - output: '"Hello, world inner!"' - runtime_cost: 20 - byte_cost: 264000 - total_cost: 264020 +diagnostics: +- Undeclared symbol `utils` at a/b/inner.rue:1:8 +- Undeclared symbol `greet` at a/b/inner.rue:4:5 From 601faade6e1bba02625064bbdeb0b060267e36f2 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Tue, 3 Feb 2026 18:46:38 -0500 Subject: [PATCH 3/3] Bump version --- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 18 +++++++++--------- crates/rue-ast/Cargo.toml | 2 +- crates/rue-cli/Cargo.toml | 2 +- crates/rue-compiler/Cargo.toml | 2 +- crates/rue-diagnostic/Cargo.toml | 2 +- crates/rue-hir/Cargo.toml | 2 +- crates/rue-lexer/Cargo.toml | 2 +- crates/rue-lir/Cargo.toml | 2 +- crates/rue-lsp/Cargo.toml | 2 +- crates/rue-options/Cargo.toml | 2 +- crates/rue-parser/Cargo.toml | 2 +- crates/rue-tests/Cargo.toml | 2 +- crates/rue-types/Cargo.toml | 2 +- wasm/Cargo.toml | 2 +- 15 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c5ef07b9..5ac25abd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1712,7 +1712,7 @@ dependencies = [ [[package]] name = "rue-ast" -version = "0.8.3" +version = "0.8.4" dependencies = [ "paste", "rue-parser", @@ -1720,7 +1720,7 @@ dependencies = [ [[package]] name = "rue-cli" -version = "0.8.3" +version = "0.8.4" dependencies = [ "anyhow", "chialisp", @@ -1738,7 +1738,7 @@ dependencies = [ [[package]] name = "rue-compiler" -version = "0.8.3" +version = "0.8.4" dependencies = [ "clvmr", "expect-test", @@ -1763,14 +1763,14 @@ dependencies = [ [[package]] name = "rue-diagnostic" -version = "0.8.3" +version = "0.8.4" dependencies = [ "thiserror 2.0.14", ] [[package]] name = "rue-hir" -version = "0.8.3" +version = "0.8.4" dependencies = [ "derive_more", "expect-test", @@ -1787,14 +1787,14 @@ dependencies = [ [[package]] name = "rue-lexer" -version = "0.8.3" +version = "0.8.4" dependencies = [ "expect-test", ] [[package]] name = "rue-lir" -version = "0.8.3" +version = "0.8.4" dependencies = [ "chialisp", "clvm-traits", @@ -1811,7 +1811,7 @@ dependencies = [ [[package]] name = "rue-lsp" -version = "0.8.3" +version = "0.8.4" dependencies = [ "indexmap", "rowan", @@ -1827,7 +1827,7 @@ dependencies = [ [[package]] name = "rue-options" -version = "0.8.3" +version = "0.8.4" dependencies = [ "serde", "thiserror 2.0.14", @@ -1836,7 +1836,7 @@ dependencies = [ [[package]] name = "rue-parser" -version = "0.8.3" +version = "0.8.4" dependencies = [ "derive_more", "expect-test", @@ -1851,7 +1851,7 @@ dependencies = [ [[package]] name = "rue-tests" -version = "0.8.3" +version = "0.8.4" dependencies = [ "anyhow", "chialisp", @@ -1868,7 +1868,7 @@ dependencies = [ [[package]] name = "rue-types" -version = "0.8.3" +version = "0.8.4" dependencies = [ "clvmr", "derive_more", @@ -1883,7 +1883,7 @@ dependencies = [ [[package]] name = "rue-wasm" -version = "0.8.3" +version = "0.8.4" dependencies = [ "chialisp", "clvmr", diff --git a/Cargo.toml b/Cargo.toml index 3a9a9e91..b989b425 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,15 +42,15 @@ cast_possible_truncation = "allow" case_sensitive_file_extension_comparisons = "allow" [workspace.dependencies] -rue-lexer = { path = "crates/rue-lexer", version = "0.8.3" } -rue-parser = { path = "crates/rue-parser", version = "0.8.3" } -rue-diagnostic = { path = "crates/rue-diagnostic", version = "0.8.3" } -rue-ast = { path = "crates/rue-ast", version = "0.8.3" } -rue-compiler = { path = "crates/rue-compiler", version = "0.8.3" } -rue-options = { path = "crates/rue-options", version = "0.8.3" } -rue-lir = { path = "crates/rue-lir", version = "0.8.3" } -rue-hir = { path = "crates/rue-hir", version = "0.8.3" } -rue-types = { path = "crates/rue-types", version = "0.8.3" } +rue-lexer = { path = "crates/rue-lexer", version = "0.8.4" } +rue-parser = { path = "crates/rue-parser", version = "0.8.4" } +rue-diagnostic = { path = "crates/rue-diagnostic", version = "0.8.4" } +rue-ast = { path = "crates/rue-ast", version = "0.8.4" } +rue-compiler = { path = "crates/rue-compiler", version = "0.8.4" } +rue-options = { path = "crates/rue-options", version = "0.8.4" } +rue-lir = { path = "crates/rue-lir", version = "0.8.4" } +rue-hir = { path = "crates/rue-hir", version = "0.8.4" } +rue-types = { path = "crates/rue-types", version = "0.8.4" } anyhow = "1.0.98" clvm-traits = "0.28.1" clvm-utils = "0.28.1" diff --git a/crates/rue-ast/Cargo.toml b/crates/rue-ast/Cargo.toml index dee291e6..079f905e 100644 --- a/crates/rue-ast/Cargo.toml +++ b/crates/rue-ast/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-ast" -version = "0.8.3" +version = "0.8.4" edition = "2024" license = "Apache-2.0" description = "An implementation of the Abstract Syntax Tree for the Rue compiler." diff --git a/crates/rue-cli/Cargo.toml b/crates/rue-cli/Cargo.toml index 7b0a7c07..abbb93b4 100644 --- a/crates/rue-cli/Cargo.toml +++ b/crates/rue-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-cli" -version = "0.8.3" +version = "0.8.4" edition = "2024" license = "Apache-2.0" description = "A CLI tool for invoking the Rue compiler." diff --git a/crates/rue-compiler/Cargo.toml b/crates/rue-compiler/Cargo.toml index 9cbe9a60..3a3dad1a 100644 --- a/crates/rue-compiler/Cargo.toml +++ b/crates/rue-compiler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-compiler" -version = "0.8.3" +version = "0.8.4" edition = "2024" license = "Apache-2.0" description = "A compiler for the Rue programming language." diff --git a/crates/rue-diagnostic/Cargo.toml b/crates/rue-diagnostic/Cargo.toml index 54b2f262..a51fd4b6 100644 --- a/crates/rue-diagnostic/Cargo.toml +++ b/crates/rue-diagnostic/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-diagnostic" -version = "0.8.3" +version = "0.8.4" edition = "2024" license = "Apache-2.0" description = "All of the potential diagnostics that can be emitted by the Rue compiler." diff --git a/crates/rue-hir/Cargo.toml b/crates/rue-hir/Cargo.toml index 8d5409f0..d51359ae 100644 --- a/crates/rue-hir/Cargo.toml +++ b/crates/rue-hir/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-hir" -version = "0.8.3" +version = "0.8.4" edition = "2024" license = "Apache-2.0" description = "Provides a high-level intermediate representation of the Rue programming language." diff --git a/crates/rue-lexer/Cargo.toml b/crates/rue-lexer/Cargo.toml index 2df0ad7b..786352e4 100644 --- a/crates/rue-lexer/Cargo.toml +++ b/crates/rue-lexer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-lexer" -version = "0.8.3" +version = "0.8.4" edition = "2024" license = "Apache-2.0" description = "A lexer for the Rue programming language." diff --git a/crates/rue-lir/Cargo.toml b/crates/rue-lir/Cargo.toml index 403b50c8..9b9598c6 100644 --- a/crates/rue-lir/Cargo.toml +++ b/crates/rue-lir/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-lir" -version = "0.8.3" +version = "0.8.4" edition = "2024" license = "Apache-2.0" description = "Provides a low-level intermediate representation that compiles to CLVM." diff --git a/crates/rue-lsp/Cargo.toml b/crates/rue-lsp/Cargo.toml index e1af12b5..73efc62b 100644 --- a/crates/rue-lsp/Cargo.toml +++ b/crates/rue-lsp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-lsp" -version = "0.8.3" +version = "0.8.4" edition = "2024" license = "Apache-2.0" description = "A language server protocol (LSP) implementation for the Rue programming language." diff --git a/crates/rue-options/Cargo.toml b/crates/rue-options/Cargo.toml index 9e74db4f..0af4fd8a 100644 --- a/crates/rue-options/Cargo.toml +++ b/crates/rue-options/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-options" -version = "0.8.3" +version = "0.8.4" edition = "2024" license = "Apache-2.0" description = "Provides a way to configure the Rue compiler." diff --git a/crates/rue-parser/Cargo.toml b/crates/rue-parser/Cargo.toml index d27bbeaa..64fc0ec8 100644 --- a/crates/rue-parser/Cargo.toml +++ b/crates/rue-parser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-parser" -version = "0.8.3" +version = "0.8.4" edition = "2024" license = "Apache-2.0" description = "A parser for the Rue programming language." diff --git a/crates/rue-tests/Cargo.toml b/crates/rue-tests/Cargo.toml index fcec076b..4eb688bc 100644 --- a/crates/rue-tests/Cargo.toml +++ b/crates/rue-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-tests" -version = "0.8.3" +version = "0.8.4" edition = "2024" publish = false license = "Apache-2.0" diff --git a/crates/rue-types/Cargo.toml b/crates/rue-types/Cargo.toml index 61d4ff96..879e7e4f 100644 --- a/crates/rue-types/Cargo.toml +++ b/crates/rue-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-types" -version = "0.8.3" +version = "0.8.4" edition = "2024" license = "Apache-2.0" description = "A type system for the Rue programming language." diff --git a/wasm/Cargo.toml b/wasm/Cargo.toml index 207e78e1..deadf136 100644 --- a/wasm/Cargo.toml +++ b/wasm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rue-wasm" -version = "0.8.3" +version = "0.8.4" edition = "2024" publish = false license = "Apache-2.0"