Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion crates/rue-ast/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
2 changes: 1 addition & 1 deletion crates/rue-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
2 changes: 1 addition & 1 deletion crates/rue-compiler/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
19 changes: 14 additions & 5 deletions crates/rue-compiler/src/compile/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ fn construct_imports(
exported: bool,
) -> Vec<ImportId> {
let mut has_non_super = false;
let mut has_super = false;

if let Some(segment) = segments.first()
&& let Some(separator) = segment.separator()
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -99,6 +103,7 @@ fn construct_imports(
items: Items::All(star),
exported,
declarations: Vec::new(),
has_super,
})]
} else if let items = last.items().collect::<Vec<_>>()
&& !items.is_empty()
Expand All @@ -124,7 +129,7 @@ fn construct_imports(

#[derive(Debug, Default)]
pub struct ImportCache {
scopes: HashMap<Vec<String>, (ScopeId, SymbolId)>,
scopes: HashMap<(ScopeId, Vec<String>), (ScopeId, SymbolId)>,
unused_imports: IndexMap<ImportId, IndexMap<String, Name>>,
glob_import_counts: IndexMap<ImportId, (Name, usize)>,
}
Expand Down Expand Up @@ -214,6 +219,7 @@ fn resolve_import(
missing_imports: &mut IndexMap<ImportId, IndexMap<String, Name>>,
) -> bool {
let import = ctx.import(import_id).clone();
let has_super = import.has_super;
let source = import.source.clone();

let mut base = None;
Expand All @@ -227,7 +233,7 @@ fn resolve_import(
.map(|t| t.text().to_string())
.collect::<Vec<_>>();

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;

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/rue-diagnostic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
2 changes: 1 addition & 1 deletion crates/rue-hir/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
1 change: 1 addition & 0 deletions crates/rue-hir/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion crates/rue-lexer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
2 changes: 1 addition & 1 deletion crates/rue-lir/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
2 changes: 1 addition & 1 deletion crates/rue-lsp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
2 changes: 1 addition & 1 deletion crates/rue-options/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
2 changes: 1 addition & 1 deletion crates/rue-parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
2 changes: 1 addition & 1 deletion crates/rue-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rue-tests"
version = "0.8.3"
version = "0.8.4"
edition = "2024"
publish = false
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/rue-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
3 changes: 3 additions & 0 deletions tests/projects/implicit_root_import.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
diagnostics:
- Undeclared symbol `utils` at a/b/inner.rue:1:8
- Undeclared symbol `greet` at a/b/inner.rue:4:5
5 changes: 5 additions & 0 deletions tests/projects/implicit_root_import/a/b/inner.rue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import utils::greet;

test fn inner() -> String {
greet("world inner")
}
5 changes: 5 additions & 0 deletions tests/projects/implicit_root_import/main.rue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import utils::greet;

fn main() -> String {
greet("world main")
}
3 changes: 3 additions & 0 deletions tests/projects/implicit_root_import/utils.rue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export fn greet(name: String) -> String {
"Hello, " + name + "!"
}
2 changes: 1 addition & 1 deletion wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rue-wasm"
version = "0.8.3"
version = "0.8.4"
edition = "2024"
publish = false
license = "Apache-2.0"
Expand Down