codegen: Rhai names cannot contain dot
This commit is contained in:
parent
f1dc2cbf18
commit
8efde3c7ce
@ -113,6 +113,14 @@ impl Parse for ExportedFnParams {
|
||||
}
|
||||
}
|
||||
|
||||
// Check validity of name, if present.
|
||||
if name.as_ref().filter(|n| n.contains('.')).is_some() {
|
||||
return Err(syn::Error::new(
|
||||
span,
|
||||
"Rhai function names may not contain dot"
|
||||
))
|
||||
}
|
||||
|
||||
Ok(ExportedFnParams {
|
||||
name,
|
||||
return_raw,
|
||||
|
28
codegen/ui_tests/rhai_fn_rename_dot.rs
Normal file
28
codegen/ui_tests/rhai_fn_rename_dot.rs
Normal file
@ -0,0 +1,28 @@
|
||||
use rhai::plugin::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Point {
|
||||
x: f32,
|
||||
y: f32,
|
||||
}
|
||||
|
||||
#[export_module]
|
||||
pub mod test_module {
|
||||
pub use super::Point;
|
||||
#[rhai_fn(name = "foo.bar")]
|
||||
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_rename_dot.stderr
Normal file
11
codegen/ui_tests/rhai_fn_rename_dot.stderr
Normal file
@ -0,0 +1,11 @@
|
||||
error: Rhai function names may not contain dot
|
||||
--> $DIR/rhai_fn_rename_dot.rs:12:15
|
||||
|
|
||||
12 | #[rhai_fn(name = "foo.bar")]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0433]: failed to resolve: use of undeclared type or module `test_module`
|
||||
--> $DIR/rhai_fn_rename_dot.rs:23:8
|
||||
|
|
||||
23 | if test_module::test_fn(n) {
|
||||
| ^^^^^^^^^^^ use of undeclared type or module `test_module`
|
Loading…
Reference in New Issue
Block a user