Skip to content

Commit

Permalink
fix: argCheck flip boolean check
Browse files Browse the repository at this point in the history
Argcheck was incorrectly checking for `true` rather than `false` for
raising an error.
  • Loading branch information
natecraddock committed Apr 1, 2023
1 parent 71e238c commit 00abb7d
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/ziglua-5.1/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ pub const Lua = struct {
/// See https://www.lua.org/manual/5.1/manual.html#luaL_argcheck
pub fn argCheck(lua: *Lua, cond: bool, arg: i32, extra_msg: [:0]const u8) void {
// translate-c failed
if (cond) lua.argError(arg, extra_msg);
if (!cond) lua.argError(arg, extra_msg);
}

/// Raises an error reporting a problem with argument `arg` of the C function that called it
Expand Down
2 changes: 1 addition & 1 deletion src/ziglua-5.1/tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ test "args and errors" {

const argCheck = ziglua.wrap(struct {
fn inner(l: *Lua) i32 {
l.argCheck(true, 1, "error!");
l.argCheck(false, 1, "error!");
return 0;
}
}.inner);
Expand Down
2 changes: 1 addition & 1 deletion src/ziglua-5.2/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ pub const Lua = struct {
/// See https://www.lua.org/manual/5.2/manual.html#lua_argcheck
pub fn argCheck(lua: *Lua, cond: bool, arg: i32, extra_msg: [:0]const u8) void {
// translate-c failed
if (cond) lua.argError(arg, extra_msg);
if (!cond) lua.argError(arg, extra_msg);
}

/// Raises an error reporting a problem with argument `arg` of the C function that called it
Expand Down
2 changes: 1 addition & 1 deletion src/ziglua-5.2/tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ test "args and errors" {

const argCheck = ziglua.wrap(struct {
fn inner(l: *Lua) i32 {
l.argCheck(true, 1, "error!");
l.argCheck(false, 1, "error!");
return 0;
}
}.inner);
Expand Down
2 changes: 1 addition & 1 deletion src/ziglua-5.3/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ pub const Lua = struct {
/// See https://www.lua.org/manual/5.3/manual.html#luaL_argcheck
pub fn argCheck(lua: *Lua, cond: bool, arg: i32, extra_msg: [:0]const u8) void {
// translate-c failed
if (cond) lua.argError(arg, extra_msg);
if (!cond) lua.argError(arg, extra_msg);
}

/// Raises an error reporting a problem with argument `arg` of the C function that called it
Expand Down
2 changes: 1 addition & 1 deletion src/ziglua-5.3/tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ test "args and errors" {

const argCheck = ziglua.wrap(struct {
fn inner(l: *Lua) i32 {
l.argCheck(true, 1, "error!");
l.argCheck(false, 1, "error!");
return 0;
}
}.inner);
Expand Down
2 changes: 1 addition & 1 deletion src/ziglua-5.4/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,7 @@ pub const Lua = struct {
/// See https://www.lua.org/manual/5.4/manual.html#lua_argcheck
pub fn argCheck(lua: *Lua, cond: bool, arg: i32, extra_msg: [:0]const u8) void {
// translate-c failed
if (cond) lua.argError(arg, extra_msg);
if (!cond) lua.argError(arg, extra_msg);
}

/// Raises an error reporting a problem with argument `arg` of the C function that called it
Expand Down
2 changes: 1 addition & 1 deletion src/ziglua-5.4/tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ test "args and errors" {

const argCheck = ziglua.wrap(struct {
fn inner(l: *Lua) i32 {
l.argCheck(true, 1, "error!");
l.argCheck(false, 1, "error!");
return 0;
}
}.inner);
Expand Down

0 comments on commit 00abb7d

Please sign in to comment.