Skip to content
Open
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
71 changes: 71 additions & 0 deletions crates/cairo-lang-semantic/src/items/tests/use_
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,74 @@ error: `self` in `use` items is not allowed for empty path.
--> lib.cairo:1:6
use {self, u8};
^^^^

//! > ==========================================================================

//! > Use star on a module that was imported with use star.

//! > test_runner_name
test_function_diagnostics(expect_diagnostics: true)

//! > function
fn foo() {
C::test();
}

//! > function_name
foo

//! > module_code
mod A {
pub mod B {
pub mod C {
pub fn test() {}
}
}
}
use A::*;
use B::*;

//! > expected_diagnostics
error[E0006]: Identifier not found.
--> lib.cairo:11:5
C::test();
^

error: Global `use` item is not supported in `V2023_01` edition.
--> lib.cairo:8:8
use A::*;
^

error[E0006]: Identifier not found.
--> lib.cairo:9:5
use B::*;
^

//! > ==========================================================================

//! > Use star on a non existing module.

//! > test_runner_name
test_function_diagnostics(expect_diagnostics: true)

//! > function
fn foo() {
C::test();
}

//! > function_name
foo

//! > module_code
use B::*;

//! > expected_diagnostics
error[E0006]: Identifier not found.
--> lib.cairo:3:5
C::test();
^

error[E0006]: Identifier not found.
--> lib.cairo:1:5
use B::*;
^
12 changes: 11 additions & 1 deletion crates/cairo-lang-semantic/src/items/us.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ pub struct ImportInfo<'db> {

/// Returns the modules that are imported with `use *` and macro calls in the current module.
/// Query implementation of [UseSemantic::module_imported_modules].
#[salsa::tracked(returns(ref))]
#[salsa::tracked(returns(ref),cycle_result=module_imported_modules_cycle)]
fn module_imported_modules<'db>(
db: &'db dyn Database,
_tracked: Tracked,
Expand Down Expand Up @@ -430,6 +430,16 @@ fn module_imported_modules<'db>(
modules
}

/// Cycle handling for [UseSemantic::module_imported_modules].
fn module_imported_modules_cycle<'db>(
_db: &'db dyn Database,
_tracked: Tracked,
_module_id: ModuleId<'db>,
) -> ImportedModules<'db> {
Default::default()
}


/// Trait for use-related semantic queries.
pub trait UseSemantic<'db>: Database {
/// Private query to compute data about a use.
Expand Down
Loading