diff --git a/src/script/common/c_converter.cpp b/src/script/common/c_converter.cpp index 5b7331e47..a8c9ace3a 100644 --- a/src/script/common/c_converter.cpp +++ b/src/script/common/c_converter.cpp @@ -199,6 +199,9 @@ v3d check_v3d(lua_State *L, int index) double y = lua_tonumber(L, -2); double z = lua_tonumber(L, -1); lua_pop(L, 3); + CHECK_FLOAT(x, "x"); + CHECK_FLOAT(y, "y"); + CHECK_FLOAT(z, "z"); return v3d(x, y, z); } diff --git a/src/unittest/test_scriptapi.cpp b/src/unittest/test_scriptapi.cpp index 4fc03e6c5..0e407daf5 100644 --- a/src/unittest/test_scriptapi.cpp +++ b/src/unittest/test_scriptapi.cpp @@ -180,4 +180,17 @@ void TestScriptApi::testVectorReadMix(MyScriptApi *script) EXCEPTION_CHECK(LuaError, check_v3s16(L, -1)); lua_pop(L, 1); } + + // same but even the result is undefined + const char *errs2[] = { + "return {x=0, y=0, z=0/0}", // nan + "return {x=0, y=0, z=math.huge}", // inf + }; + for (auto &it : errs2) { + infostream << it << std::endl; + run(L, it, 1); + (void)read_v3s16(L, -1); + EXCEPTION_CHECK(LuaError, check_v3s16(L, -1)); + lua_pop(L, 1); + } }