Skip to content

Commit

Permalink
Convert enum values to number for LuaJIT 2.0.5 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
jkl1337 committed Feb 18, 2024
1 parent 2ffc5a3 commit b3cf613
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
6 changes: 4 additions & 2 deletions kiwi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b3cf613

Please sign in to comment.