-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
LuaBridge3/Distribution/LuaBridge/LuaBridge.h
Lines 4369 to 4381 in d6ff443
| [[nodiscard]] static Result push(lua_State* L, float value) | |
| { | |
| #if LUABRIDGE_SAFE_STACK_CHECKS | |
| if (! lua_checkstack(L, 1)) | |
| return makeErrorCode(ErrorCode::LuaStackOverflow); | |
| #endif | |
| if (! is_floating_point_representable_by(value)) | |
| return makeErrorCode(ErrorCode::FloatingPointDoesntFitIntoLuaNumber); | |
| lua_pushnumber(L, static_cast<lua_Number>(value)); | |
| return {}; | |
| } |
Currently, Stack<float>::push() rejects NaN and Inf values with FloatingPointDoesntFitIntoLuaNumber error before they can reach Lua. This prevents applications from handling these special floating-point values in the application logic.
Since Lua supports NaN/Inf, should we allow NaN and Inf values to pass through to Lua where they can be properly handled by application logic?
// In Stack<float>::push()
if (std::isnan(value) || std::isinf(value)) {
lua_pushnumber(L, static_cast<lua_Number>(value));
return {};
}
Metadata
Metadata
Assignees
Labels
No labels