diff --git a/codegen/ui_tests/export_mod_raw_noreturn.rs b/codegen/ui_tests/export_mod_raw_noreturn.rs new file mode 100644 index 00000000..926f6286 --- /dev/null +++ b/codegen/ui_tests/export_mod_raw_noreturn.rs @@ -0,0 +1,28 @@ +use rhai::plugin::*; + +#[derive(Clone)] +struct Point { + x: f32, + y: f32, +} + +#[export_module] +pub mod test_mod { +#[rhai_fn(return_raw)] +pub fn test_fn(input: &mut Point) { + input.x += 1.0; +} +} + +fn main() { + let n = Point { + x: 0.0, + y: 10.0, + }; + test_mod::test_fn(&mut n); + if n.x >= 10.0 { + println!("yes"); + } else { + println!("no"); + } +} diff --git a/codegen/ui_tests/export_mod_raw_noreturn.stderr b/codegen/ui_tests/export_mod_raw_noreturn.stderr new file mode 100644 index 00000000..a548f339 --- /dev/null +++ b/codegen/ui_tests/export_mod_raw_noreturn.stderr @@ -0,0 +1,11 @@ +error: return_raw functions must return Result + --> $DIR/export_mod_raw_noreturn.rs:12:5 + | +12 | pub fn test_fn(input: &mut Point) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0433]: failed to resolve: use of undeclared type or module `test_mod` + --> $DIR/export_mod_raw_noreturn.rs:22:5 + | +22 | test_mod::test_fn(&mut n); + | ^^^^^^^^ use of undeclared type or module `test_mod` diff --git a/codegen/ui_tests/export_mod_raw_return.rs b/codegen/ui_tests/export_mod_raw_return.rs new file mode 100644 index 00000000..ae52301e --- /dev/null +++ b/codegen/ui_tests/export_mod_raw_return.rs @@ -0,0 +1,27 @@ +use rhai::plugin::*; + +#[derive(Clone)] +struct Point { + x: f32, + y: f32, +} + +#[export_module] +pub mod test_mod { +#[rhai_fn(return_raw)] +pub fn test_fn(input: Point) -> bool { + input.x > input.y +} +} + +fn main() { + let n = Point { + x: 0.0, + y: 10.0, + }; + if test_mod::test_fn(n) { + println!("yes"); + } else { + println!("no"); + } +} diff --git a/codegen/ui_tests/export_mod_raw_return.stderr b/codegen/ui_tests/export_mod_raw_return.stderr new file mode 100644 index 00000000..7d22f7a2 --- /dev/null +++ b/codegen/ui_tests/export_mod_raw_return.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/export_mod_raw_return.rs:12:8 + | +9 | #[export_module] + | ---------------- expected `std::result::Result>` because of return type +... +12 | pub fn test_fn(input: Point) -> bool { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found `bool` + | + = note: expected enum `std::result::Result>` + found type `bool`