Add rhai_fn nested attribute and skip fn parameter
This commit is contained in:
27
codegen/ui_tests/rhai_fn_bad_attr.rs
Normal file
27
codegen/ui_tests/rhai_fn_bad_attr.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use rhai::plugin::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Point {
|
||||
x: f32,
|
||||
y: f32,
|
||||
}
|
||||
|
||||
#[export_module]
|
||||
pub mod test_module {
|
||||
#[rhai_fn(unknown = "thing")]
|
||||
pub fn test_fn(input: Point) -> bool {
|
||||
input.x > input.y
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let n = Point {
|
||||
x: 0.0,
|
||||
y: 10.0,
|
||||
};
|
||||
if test_module::test_fn(n) {
|
||||
println!("yes");
|
||||
} else {
|
||||
println!("no");
|
||||
}
|
||||
}
|
11
codegen/ui_tests/rhai_fn_bad_attr.stderr
Normal file
11
codegen/ui_tests/rhai_fn_bad_attr.stderr
Normal file
@@ -0,0 +1,11 @@
|
||||
error: unknown attribute 'unknown'
|
||||
--> $DIR/rhai_fn_bad_attr.rs:11:11
|
||||
|
|
||||
11 | #[rhai_fn(unknown = "thing")]
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0433]: failed to resolve: use of undeclared type or module `test_module`
|
||||
--> $DIR/rhai_fn_bad_attr.rs:22:8
|
||||
|
|
||||
22 | if test_module::test_fn(n) {
|
||||
| ^^^^^^^^^^^ use of undeclared type or module `test_module`
|
27
codegen/ui_tests/rhai_fn_bad_value.rs
Normal file
27
codegen/ui_tests/rhai_fn_bad_value.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use rhai::plugin::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Point {
|
||||
x: f32,
|
||||
y: f32,
|
||||
}
|
||||
|
||||
#[export_module]
|
||||
pub mod test_module {
|
||||
#[rhai_fn(name = true)]
|
||||
pub fn test_fn(input: Point) -> bool {
|
||||
input.x > input.y
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let n = Point {
|
||||
x: 0.0,
|
||||
y: 10.0,
|
||||
};
|
||||
if test_module::test_fn(n) {
|
||||
println!("yes");
|
||||
} else {
|
||||
println!("no");
|
||||
}
|
||||
}
|
11
codegen/ui_tests/rhai_fn_bad_value.stderr
Normal file
11
codegen/ui_tests/rhai_fn_bad_value.stderr
Normal file
@@ -0,0 +1,11 @@
|
||||
error: expecting string literal
|
||||
--> $DIR/rhai_fn_bad_value.rs:11:18
|
||||
|
|
||||
11 | #[rhai_fn(name = true)]
|
||||
| ^^^^
|
||||
|
||||
error[E0433]: failed to resolve: use of undeclared type or module `test_module`
|
||||
--> $DIR/rhai_fn_bad_value.rs:22:8
|
||||
|
|
||||
22 | if test_module::test_fn(n) {
|
||||
| ^^^^^^^^^^^ use of undeclared type or module `test_module`
|
27
codegen/ui_tests/rhai_fn_extra_value.rs
Normal file
27
codegen/ui_tests/rhai_fn_extra_value.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use rhai::plugin::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Point {
|
||||
x: f32,
|
||||
y: f32,
|
||||
}
|
||||
|
||||
#[export_module]
|
||||
pub mod test_module {
|
||||
#[rhai_fn(return_raw = "yes")]
|
||||
pub fn test_fn(input: Point) -> bool {
|
||||
input.x > input.y
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let n = Point {
|
||||
x: 0.0,
|
||||
y: 10.0,
|
||||
};
|
||||
if test_module::test_fn(n) {
|
||||
println!("yes");
|
||||
} else {
|
||||
println!("no");
|
||||
}
|
||||
}
|
11
codegen/ui_tests/rhai_fn_extra_value.stderr
Normal file
11
codegen/ui_tests/rhai_fn_extra_value.stderr
Normal file
@@ -0,0 +1,11 @@
|
||||
error: extraneous value
|
||||
--> $DIR/rhai_fn_extra_value.rs:11:24
|
||||
|
|
||||
11 | #[rhai_fn(return_raw = "yes")]
|
||||
| ^^^^^
|
||||
|
||||
error[E0433]: failed to resolve: use of undeclared type or module `test_module`
|
||||
--> $DIR/rhai_fn_extra_value.rs:22:8
|
||||
|
|
||||
22 | if test_module::test_fn(n) {
|
||||
| ^^^^^^^^^^^ use of undeclared type or module `test_module`
|
27
codegen/ui_tests/rhai_fn_junk_arg.rs
Normal file
27
codegen/ui_tests/rhai_fn_junk_arg.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use rhai::plugin::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Point {
|
||||
x: f32,
|
||||
y: f32,
|
||||
}
|
||||
|
||||
#[export_module]
|
||||
pub mod test_module {
|
||||
#[rhai_fn("wheeeee")]
|
||||
pub fn test_fn(input: Point) -> bool {
|
||||
input.x > input.y
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let n = Point {
|
||||
x: 0.0,
|
||||
y: 10.0,
|
||||
};
|
||||
if test_module::test_fn(n) {
|
||||
println!("yes");
|
||||
} else {
|
||||
println!("no");
|
||||
}
|
||||
}
|
11
codegen/ui_tests/rhai_fn_junk_arg.stderr
Normal file
11
codegen/ui_tests/rhai_fn_junk_arg.stderr
Normal file
@@ -0,0 +1,11 @@
|
||||
error: expecting identifier
|
||||
--> $DIR/rhai_fn_junk_arg.rs:11:11
|
||||
|
|
||||
11 | #[rhai_fn("wheeeee")]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error[E0433]: failed to resolve: use of undeclared type or module `test_module`
|
||||
--> $DIR/rhai_fn_junk_arg.rs:22:8
|
||||
|
|
||||
22 | if test_module::test_fn(n) {
|
||||
| ^^^^^^^^^^^ use of undeclared type or module `test_module`
|
27
codegen/ui_tests/rhai_fn_missing_value.rs
Normal file
27
codegen/ui_tests/rhai_fn_missing_value.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use rhai::plugin::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Point {
|
||||
x: f32,
|
||||
y: f32,
|
||||
}
|
||||
|
||||
#[export_module]
|
||||
pub mod test_module {
|
||||
#[rhai_fn(name)]
|
||||
pub fn test_fn(input: Point) -> bool {
|
||||
input.x > input.y
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let n = Point {
|
||||
x: 0.0,
|
||||
y: 10.0,
|
||||
};
|
||||
if test_module::test_fn(n) {
|
||||
println!("yes");
|
||||
} else {
|
||||
println!("no");
|
||||
}
|
||||
}
|
11
codegen/ui_tests/rhai_fn_missing_value.stderr
Normal file
11
codegen/ui_tests/rhai_fn_missing_value.stderr
Normal file
@@ -0,0 +1,11 @@
|
||||
error: requires value
|
||||
--> $DIR/rhai_fn_missing_value.rs:11:11
|
||||
|
|
||||
11 | #[rhai_fn(name)]
|
||||
| ^^^^
|
||||
|
||||
error[E0433]: failed to resolve: use of undeclared type or module `test_module`
|
||||
--> $DIR/rhai_fn_missing_value.rs:22:8
|
||||
|
|
||||
22 | if test_module::test_fn(n) {
|
||||
| ^^^^^^^^^^^ use of undeclared type or module `test_module`
|
27
codegen/ui_tests/rhai_fn_path_attr.rs
Normal file
27
codegen/ui_tests/rhai_fn_path_attr.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use rhai::plugin::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Point {
|
||||
x: f32,
|
||||
y: f32,
|
||||
}
|
||||
|
||||
#[export_module]
|
||||
pub mod test_module {
|
||||
#[rhai_fn(rhai::name = "thing")]
|
||||
pub fn test_fn(input: Point) -> bool {
|
||||
input.x > input.y
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let n = Point {
|
||||
x: 0.0,
|
||||
y: 10.0,
|
||||
};
|
||||
if test_module::test_fn(n) {
|
||||
println!("yes");
|
||||
} else {
|
||||
println!("no");
|
||||
}
|
||||
}
|
11
codegen/ui_tests/rhai_fn_path_attr.stderr
Normal file
11
codegen/ui_tests/rhai_fn_path_attr.stderr
Normal file
@@ -0,0 +1,11 @@
|
||||
error: expecting attribute name
|
||||
--> $DIR/rhai_fn_path_attr.rs:11:11
|
||||
|
|
||||
11 | #[rhai_fn(rhai::name = "thing")]
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error[E0433]: failed to resolve: use of undeclared type or module `test_module`
|
||||
--> $DIR/rhai_fn_path_attr.rs:22:8
|
||||
|
|
||||
22 | if test_module::test_fn(n) {
|
||||
| ^^^^^^^^^^^ use of undeclared type or module `test_module`
|
Reference in New Issue
Block a user