//! > Test PathNotFound.
//! > test_runner_name
test_expr_diagnostics(expect_diagnostics: true)
//! > expr_code
{
}
//! > module_code
fn foo() -> UnknownType {
bar();
}
//! > function_body
//! > expected_diagnostics
error[E0006]: Type not found.
--> lib.cairo:1:13
fn foo() -> UnknownType {
^^^^^^^^^^^
error[E0006]: Function not found.
--> lib.cairo:2:5
bar();
^^^
//! > ==========================================================================
//! > Test trying to access a function from a module whose file is missing.
//! > test_runner_name
test_expr_diagnostics(expect_diagnostics: true)
//! > expr_code
module_does_not_exist::bar()
//! > module_code
mod module_does_not_exist;
//! > function_body
//! > expected_diagnostics
error[E0005]: Module file not found. Expected path: module_does_not_exist.cairo
--> lib.cairo:1:1
mod module_does_not_exist;
^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0006]: Function not found.
--> lib.cairo:3:24
module_does_not_exist::bar()
^^^
//! > ==========================================================================
//! > Test missing implicit in implicit_precedence
//! > test_runner_name
test_expr_diagnostics(expect_diagnostics: true)
//! > expr_code
{}
//! > module_code
#[implicit_precedence(MissingBuiltin1, MissingBuiltin2)]
fn foo() {}
//! > function_body
//! > expected_diagnostics
error[E0006]: Type not found.
--> lib.cairo:1:23
#[implicit_precedence(MissingBuiltin1, MissingBuiltin2)]
^^^^^^^^^^^^^^^
//! > ==========================================================================
//! > Test matching imports for missing methods.
//! > test_runner_name
test_expr_diagnostics(expect_diagnostics: true)
//! > expr_code
{
let struct_a = A {a: 0};
struct_a.foo()
}
//! > module_code
struct A {
a: felt252,
}
mod module {
use super::A;
pub trait Trt1 {
fn foo(self: A) -> felt252;
}
impl Imp1 of Trt1 {
fn foo(self: A) -> felt252 {
0
}
}
}
//! > function_body
//! > expected_diagnostics
error[E0002]: Method `foo` not found on type `test::A`. Consider importing one of the following traits: `module::Trt1`.
--> lib.cairo:18:14
struct_a.foo()
^^^
//! > ==========================================================================
//! > Test multiple matching imports for missing methods.
//! > test_runner_name
test_expr_diagnostics(expect_diagnostics: true)
//! > expr_code
a.foo()
//! > module_code
struct A {
a: felt252,
}
mod b {
use super::A;
#[generate_trait]
pub impl Imp1 of Trt1 {
fn foo(self: A) {}
}
#[generate_trait]
pub impl Imp2 of Trt2 {
fn foo(self: A) {}
}
}
//! > function_body
let a = A {a: 0};
//! > expected_diagnostics
error[E0002]: Method `foo` not found on type `test::A`. Consider importing one of the following traits: `b::Trt1`, `b::Trt2`.
--> lib.cairo:16:3
a.foo()
^^^
//! > ==========================================================================
//! > Test matching imports for missing methods from external crates.
//! > test_runner_name
test_expr_diagnostics(expect_diagnostics: true)
//! > expr_code
9_u32.sqrt()
//! > function_body
//! > expected_diagnostics
error[E0002]: Method `sqrt` not found on type `core::integer::u32`. Consider importing one of the following traits: `core::num::traits::Sqrt`.
--> lib.cairo:2:7
9_u32.sqrt()
^^^^
//! > ==========================================================================
//! > Test matching imports for missing methods from external crates.asdfasdfa
//! > test_runner_name
test_expr_diagnostics(expect_diagnostics: true)
//! > expr_code
1_u32.foo()
//! > module_code
pub mod a {
pub mod b {
trait Trt<T> {
fn foo(self: T) -> T;
}
pub impl TrtImpl of Trt<u32> {
fn foo(self: u32) -> u32 {
self
}
}
}
mod c {
fn foo2() {
2_u32.foo();
}
mod d {
fn foo3() {
3_u32.foo();
}
mod e {
fn foo4() {
4_u32.foo();
}
}
}
}
}
//! > function_body
//! > expected_diagnostics
error[E0002]: Method `foo` not found on type `core::integer::u32`. Consider importing one of the following traits: `a::b::Trt`.
--> lib.cairo:29:7
1_u32.foo()
^^^
error[E0002]: Method `foo` not found on type `core::integer::u32`. Consider importing one of the following traits: `super::b::Trt`.
--> lib.cairo:14:19
2_u32.foo();
^^^
error[E0002]: Method `foo` not found on type `core::integer::u32`. Consider importing one of the following traits: `crate::a::b::Trt`.
--> lib.cairo:18:23
3_u32.foo();
^^^
error[E0002]: Method `foo` not found on type `core::integer::u32`. Consider importing one of the following traits: `crate::a::b::Trt`.
--> lib.cairo:22:27
4_u32.foo();
^^^