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
2 changes: 0 additions & 2 deletions crates/rue-air/src/sema/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ pub enum ImportResolution {
/// Exactly one directive names it, but the specifier is malformed (it
/// normalizes to an empty module path).
Rejected,
/// Multiple directives in the consulting module name the same target.
Ambiguous,
}

/// Whether a receiver member is an instance method (takes a `self` receiver) or
Expand Down
4 changes: 2 additions & 2 deletions crates/rue-cli-tests/cases/array_element_module.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ compile_fail = true
error_contains = ["E0206", "<module>"]
files = [
{ path = "main.rue", source = """
fn main() -> i32 { let h = @import("helper"); let arr = [h, h]; 0 }
fn main() -> i32 { let h = @import("helper.rue"); let arr = [h, h]; 0 }
""" },
{ path = "helper.rue", source = """
pub fn value() -> i32 { 1 }
Expand All @@ -37,7 +37,7 @@ compile_fail = true
error_contains = ["E0206", "<module>"]
files = [
{ path = "main.rue", source = """
fn main() -> i32 { let h = @import("helper"); let arr = [h; 3]; 0 }
fn main() -> i32 { let h = @import("helper.rue"); let arr = [h; 3]; 0 }
""" },
{ path = "helper.rue", source = """
pub fn value() -> i32 { 1 }
Expand Down
8 changes: 4 additions & 4 deletions crates/rue-cli-tests/cases/assoc_fn_privacy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ description = "Cross-directory associated-function calls on a private struct are
name = "cross_dir_unqualified_private_assoc_fn_rejected"
files = [
{ path = "main.rue", source = """
const lib = @import("sub/lib");
const lib = @import("sub/lib.rue");

fn main() -> i32 {
let s = Secret.make();
Expand All @@ -41,7 +41,7 @@ error_contains = ["E0201", "undefined variable 'Secret'"]
name = "cross_dir_qualified_private_assoc_fn_rejected"
files = [
{ path = "main.rue", source = """
const lib = @import("sub/lib");
const lib = @import("sub/lib.rue");

fn main() -> i32 {
let s = lib.Secret.make();
Expand All @@ -63,7 +63,7 @@ error_contains = ["E0706", "struct `Secret` is private"]
name = "cross_dir_pub_assoc_fn_allowed"
files = [
{ path = "main.rue", source = """
const lib = @import("sub/lib");
const lib = @import("sub/lib.rue");

fn main() -> i32 {
let p = lib.Point.origin();
Expand Down Expand Up @@ -109,7 +109,7 @@ exit_code = 42
name = "cross_dir_comptime_bound_assoc_fn_allowed"
files = [
{ path = "main.rue", source = """
const lib = @import("sub/lib");
const lib = @import("sub/lib.rue");

fn main() -> i32 {
let P = lib.Point;
Expand Down
8 changes: 4 additions & 4 deletions crates/rue-cli-tests/cases/byref_params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ description = "Passing the same variable to two inout parameters of a module mem
files = [
{ path = "main.rue", source = """
fn main() -> i32 {
let m = @import("mod_swap");
let m = @import("mod_swap.rue");
let mut x = 1;
m.swap(inout x, inout x);
0
Expand All @@ -463,7 +463,7 @@ description = "Passing the same variable as both borrow and inout to a module me
files = [
{ path = "main.rue", source = """
fn main() -> i32 {
let m = @import("mod_obs");
let m = @import("mod_obs.rue");
let mut x = 1;
m.observe(borrow x, inout x)
}
Expand All @@ -486,7 +486,7 @@ fn observe(borrow a: i32, inout b: i32) -> i32 {
a + b
}
fn main() -> i32 {
let m = @import("helper");
let m = @import("helper.rue");
let _ = m.one();
let mut x = 5;
observe(borrow x, inout x)
Expand All @@ -507,7 +507,7 @@ description = "Control: distinct variables passed by-ref to a module member call
files = [
{ path = "main.rue", source = """
fn main() -> i32 {
let m = @import("mod_swap");
let m = @import("mod_swap.rue");
let mut x = 1;
let mut y = 41;
m.swap(inout x, inout y);
Expand Down
2 changes: 1 addition & 1 deletion crates/rue-cli-tests/cases/comptime_value_params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ name = "module_member_call_with_comptime_param"
description = "Calling a comptime-value function through a module object routes through specialization."
files = [
{ path = "main.rue", source = """
const util = @import("util");
const util = @import("util.rue");
fn main() -> i32 {
@dbg(util.scale(5, 7));
0
Expand Down
2 changes: 1 addition & 1 deletion crates/rue-cli-tests/cases/const_init.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ exit_code = 3
name = "module_binding_exempt_from_annotation"
files = [
{ path = "main.rue", source = """
const cfg = @import("cfg");
const cfg = @import("cfg.rue");
const X: i32 = cfg.ANSWER;

fn main() -> i32 {
Expand Down
2 changes: 1 addition & 1 deletion crates/rue-cli-tests/cases/diagnostic_json.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ JSON formatter shares with the text formatter (RUE-175).
"""
files = [
{ path = "main.rue", source = """
const helper = @import("helper");
const helper = @import("helper.rue");

fn main() -> i32 {
let bad: i32 = true;
Expand Down
2 changes: 1 addition & 1 deletion crates/rue-cli-tests/cases/emit_pipeline.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ name = "emit_air_resolves_modules"
description = "--emit skipped sema.set_file_paths, so module programs failed E0704 only under --emit (RUE-130 item 4)."
files = [
{ path = "main.rue", source = """
const utils = @import("utils");
const utils = @import("utils.rue");

fn main() -> i32 {
utils.triple(2)
Expand Down
4 changes: 2 additions & 2 deletions crates/rue-cli-tests/cases/float_literals.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ points into the module that wrote it.
files = [
{ path = "main.rue", source = """
fn main() -> i32 {
let h = @import("helper");
let h = @import("helper.rue");
h.scale()
}
""" },
Expand All @@ -152,7 +152,7 @@ description = "The gate follows the literal across the module boundary and repor
files = [
{ path = "main.rue", source = """
fn main() -> i32 {
let h = @import("helper");
let h = @import("helper.rue");
h.scale()
}
""" },
Expand Down
30 changes: 15 additions & 15 deletions crates/rue-cli-tests/cases/module_consts.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ description = "Value consts as module members, module aliases, and const-context
name = "value_const_as_module_member"
files = [
{ path = "main.rue", source = """
const math = @import("math");
const math = @import("math.rue");

fn main() -> i32 {
math.ANSWER
Expand All @@ -33,8 +33,8 @@ exit_code = 42
name = "same_named_value_consts_in_distinct_modules"
files = [
{ path = "main.rue", source = """
const a = @import("a");
const b = @import("b");
const a = @import("a.rue");
const b = @import("b.rue");

fn main() -> i32 {
a.VALUE + b.VALUE
Expand All @@ -54,7 +54,7 @@ exit_code = 3
name = "member_const_in_const_initializer"
files = [
{ path = "main.rue", source = """
const math = @import("math");
const math = @import("math.rue");
const COPY: i32 = math.ANSWER;

fn main() -> i32 {
Expand All @@ -75,7 +75,7 @@ exit_code = 42
name = "member_const_as_operator_operand"
files = [
{ path = "main.rue", source = """
const math = @import("math");
const math = @import("math.rue");
const A: i32 = 1 + math.ANSWER;
const B: i32 = math.ANSWER * 2 - 4;

Expand All @@ -96,7 +96,7 @@ exit_code = 123
name = "private_member_as_operator_operand_rejected"
files = [
{ path = "main.rue", source = """
const lib = @import("sub/lib");
const lib = @import("sub/lib.rue");
const A: i32 = 1 + lib.SECRET;

fn main() -> i32 { A }
Expand All @@ -115,7 +115,7 @@ error_contains = ["E0706", "SECRET", "private"]
name = "i64_member_const_keeps_width"
files = [
{ path = "main.rue", source = """
const cfg = @import("cfg");
const cfg = @import("cfg.rue");

fn main() -> i32 {
if cfg.BIG / 1000000000 == 5 { 9 } else { 1 }
Expand Down Expand Up @@ -176,7 +176,7 @@ fn main() -> i32 {
}
""" },
{ path = "outer/_outer.rue", source = """
pub const inner = @import("inner");
pub const inner = @import("inner.rue");
""" },
{ path = "outer/inner.rue", source = """
pub fn value() -> i32 { 42 }
Expand All @@ -189,7 +189,7 @@ exit_code = 42
name = "pub_member_const_across_directories"
files = [
{ path = "main.rue", source = """
const lib = @import("sub/lib");
const lib = @import("sub/lib.rue");

fn main() -> i32 {
lib.LIMIT
Expand All @@ -206,7 +206,7 @@ exit_code = 17
name = "private_member_const_rejected_at_use"
files = [
{ path = "main.rue", source = """
const lib = @import("sub/lib");
const lib = @import("sub/lib.rue");

fn main() -> i32 {
lib.SECRET
Expand All @@ -225,7 +225,7 @@ error_contains = ["E0706", "SECRET", "private"]
name = "private_member_const_rejected_in_const_context"
files = [
{ path = "main.rue", source = """
const lib = @import("sub/lib");
const lib = @import("sub/lib.rue");
const S: i32 = lib.SECRET;

fn main() -> i32 { S }
Expand All @@ -243,7 +243,7 @@ error_contains = ["E0706", "SECRET", "private"]
name = "private_member_const_same_directory_ok"
files = [
{ path = "main.rue", source = """
const lib = @import("lib");
const lib = @import("lib.rue");

fn main() -> i32 {
lib.SECRET
Expand All @@ -262,7 +262,7 @@ name = "fn_member_const_alias_call"
description = "A module-member function const creates a callable alias (spec 6.5:15), and calling the alias is equivalent to calling the function (spec 4.10:12)."
files = [
{ path = "main.rue", source = """
const abs_alias = @import("math").abs;
const abs_alias = @import("math.rue").abs;

fn main() -> i32 { abs_alias(0 - 42) }
""" },
Expand Down Expand Up @@ -310,7 +310,7 @@ error_contains = ["E0434", "a function reference is not supported in const conte
name = "unknown_member_still_e0707"
files = [
{ path = "main.rue", source = """
const math = @import("math");
const math = @import("math.rue");
const X: i32 = math.NOPE;

fn main() -> i32 { 0 }
Expand All @@ -329,7 +329,7 @@ name = "value_const_member_through_local_let"
files = [
{ path = "main.rue", source = """
fn main() -> i32 {
let m = @import("math");
let m = @import("math.rue");
@dbg(m.ANSWER);
0
}
Expand Down
32 changes: 18 additions & 14 deletions crates/rue-cli-tests/cases/module_importer_relative.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ description = "Relative @import resolves against the importing file's own direct
name = "same_import_string_resolves_per_directory"
files = [
{ path = "main.rue", source = """
const a = @import("a/mod_a");
const b = @import("b/mod_b");
const a = @import("a/mod_a.rue");
const b = @import("b/mod_b.rue");

fn main() -> i32 {
@dbg(a.a_val());
Expand All @@ -30,14 +30,14 @@ fn main() -> i32 {
}
""" },
{ path = "a/mod_a.rue", source = """
const foo = @import("foo");
const foo = @import("foo.rue");
pub fn a_val() -> i32 { foo.a_foo() }
""" },
{ path = "a/foo.rue", source = """
pub fn a_foo() -> i32 { 10 }
""" },
{ path = "b/mod_b.rue", source = """
const foo = @import("foo");
const foo = @import("foo.rue");
pub fn b_val() -> i32 { foo.b_foo() }
""" },
{ path = "b/foo.rue", source = """
Expand Down Expand Up @@ -74,8 +74,8 @@ exit_code = 15
name = "file_module_and_facade_in_different_dirs_are_not_ambiguous"
files = [
{ path = "main.rue", source = """
const u1 = @import("sub/user1");
const u2 = @import("facdir/user2");
const u1 = @import("sub/user1.rue");
const u2 = @import("facdir/user2.rue");

fn main() -> i32 {
@dbg(u1.one());
Expand All @@ -84,7 +84,7 @@ fn main() -> i32 {
}
""" },
{ path = "sub/user1.rue", source = """
const foo = @import("foo");
const foo = @import("foo.rue");
pub fn one() -> i32 { foo.sfoo() }
""" },
{ path = "sub/foo.rue", source = """
Expand All @@ -100,14 +100,19 @@ pub fn dfoo() -> i32 { 4 }
]
stdout = "3\n4\n"

# A genuine dual-entity ambiguity within ONE directory still errors (E0708):
# both `foo.rue` and `foo/_foo.rue` sit next to the importer.
# Both forms in ONE directory coexist (ADR-0078): the extensionless spelling
# names the facade, the extensioned spelling names the file. E0708 is retired.
[[case]]
name = "genuine_single_dir_ambiguity_still_errors"
name = "both_forms_in_one_dir_resolve_by_spelling"
files = [
{ path = "main.rue", source = """
const foo = @import("foo");
fn main() -> i32 { foo.v_file() }
const facade = @import("foo");
const file = @import("foo.rue");
fn main() -> i32 {
@dbg(file.v_file());
@dbg(facade.v_dir());
0
}
""" },
{ path = "foo.rue", source = """
pub fn v_file() -> i32 { 1 }
Expand All @@ -116,5 +121,4 @@ pub fn v_file() -> i32 { 1 }
pub fn v_dir() -> i32 { 2 }
""" },
]
compile_fail = true
error_contains = ["E0708", "foo"]
stdout = "1\n2\n"
Loading