Convert enum values to number for LuaJIT 2.0.5 compat

This commit is contained in:
2024-02-17 22:03:25 -06:00
parent 2ffc5a333b
commit b3cf6136a4
2 changed files with 5 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
ljkiwi - Free LuaJIT FFI kiwi (Cassowary derived) constraint solver.
[![CI](https://github.com/jkl1337/ljkiwi/actions/workflows/ci.yml/badge.svg)](https://github.com/jkl1337/ljkiwi/actions/workflows/ci.yml)
[![CI](https://github.com/jkl1337/ljkiwi/actions/workflows/busted.yml/badge.svg)](https://github.com/jkl1337/ljkiwi/actions/workflows/busted.yml)
[![Coverage Status](https://coveralls.io/repos/github/jkl1337/ljkiwi/badge.svg?branch=master)](https://coveralls.io/github/jkl1337/ljkiwi?branch=master)
[![luarocks](https://img.shields.io/luarocks/v/jkl/ljkiwi)](https://luarocks.org/modules/jkl/ljkiwi)

View File

@@ -871,7 +871,8 @@ do
function kiwi.error_mask(kinds, invert)
local mask = 0
for _, k in ipairs(kinds) do
mask = bor(mask, lshift(1, kiwi.ErrKind(k)))
-- must use tonumber only for LuaJIT 2.0 compatibility
mask = bor(mask, lshift(1, tonumber(kiwi.ErrKind(k)) --[[@as integer]]))
end
return invert and bit.bnot(mask) or mask
end
@@ -940,8 +941,9 @@ do
end
local errdata = new_error(kind, message, solver, item)
local error_mask = solver and solver.error_mask_ or 0
-- tonumber only required for LuaJIT 2.0 compatibility
return item,
band(error_mask, lshift(1, kind --[[@as integer]])) == 0 and error(errdata)
band(error_mask, lshift(1, tonumber(kind) --[[@as integer]])) == 0 and error(errdata)
or errdata
end
return item