tomaka / hlua

Rust library to interface with Lua
MIT License
510 stars 48 forks source link

Passing excessive arguments to Rust functions doesn't cause errors #187

Open mkpankov opened 6 years ago

mkpankov commented 6 years ago

Paste the following test to hlua/hlua/src/functions_write.rs (mod tests):

    #[test]
    fn simple_function_excessive_arguments() {
        let mut lua = Lua::new();

        fn ret5() -> i32 {
            5
        };
        lua.set("ret5", function0(ret5));

        let val: i32 = lua.execute("return ret5(1)").unwrap();
        assert_eq!(val, 5);
    }

Then cargo test simple_function_excessive_arguments:

running 1 test
test functions_write::tests::simple_function_excessive_arguments ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 72 filtered out

It doesn't fail.

I expected "wrong parameters for callback" as it's done when types you pass from Lua don't match Rust ones.

Now it seems excessive arguments are just ignored, which makes it harder to make sure Lua call sites are correct and in sync with Rust.