Skip to content

Commit 00abb7d

Browse files
committedApr 1, 2023
fix: argCheck flip boolean check
Argcheck was incorrectly checking for `true` rather than `false` for raising an error.
1 parent 71e238c commit 00abb7d

File tree

8 files changed

+8
-8
lines changed

8 files changed

+8
-8
lines changed
 

‎src/ziglua-5.1/lib.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ pub const Lua = struct {
11061106
/// See https://www.lua.org/manual/5.1/manual.html#luaL_argcheck
11071107
pub fn argCheck(lua: *Lua, cond: bool, arg: i32, extra_msg: [:0]const u8) void {
11081108
// translate-c failed
1109-
if (cond) lua.argError(arg, extra_msg);
1109+
if (!cond) lua.argError(arg, extra_msg);
11101110
}
11111111

11121112
/// Raises an error reporting a problem with argument `arg` of the C function that called it

‎src/ziglua-5.1/tests.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ test "args and errors" {
11341134

11351135
const argCheck = ziglua.wrap(struct {
11361136
fn inner(l: *Lua) i32 {
1137-
l.argCheck(true, 1, "error!");
1137+
l.argCheck(false, 1, "error!");
11381138
return 0;
11391139
}
11401140
}.inner);

‎src/ziglua-5.2/lib.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ pub const Lua = struct {
12981298
/// See https://www.lua.org/manual/5.2/manual.html#lua_argcheck
12991299
pub fn argCheck(lua: *Lua, cond: bool, arg: i32, extra_msg: [:0]const u8) void {
13001300
// translate-c failed
1301-
if (cond) lua.argError(arg, extra_msg);
1301+
if (!cond) lua.argError(arg, extra_msg);
13021302
}
13031303

13041304
/// Raises an error reporting a problem with argument `arg` of the C function that called it

‎src/ziglua-5.2/tests.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1274,7 +1274,7 @@ test "args and errors" {
12741274

12751275
const argCheck = ziglua.wrap(struct {
12761276
fn inner(l: *Lua) i32 {
1277-
l.argCheck(true, 1, "error!");
1277+
l.argCheck(false, 1, "error!");
12781278
return 0;
12791279
}
12801280
}.inner);

‎src/ziglua-5.3/lib.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ pub const Lua = struct {
13501350
/// See https://www.lua.org/manual/5.3/manual.html#luaL_argcheck
13511351
pub fn argCheck(lua: *Lua, cond: bool, arg: i32, extra_msg: [:0]const u8) void {
13521352
// translate-c failed
1353-
if (cond) lua.argError(arg, extra_msg);
1353+
if (!cond) lua.argError(arg, extra_msg);
13541354
}
13551355

13561356
/// Raises an error reporting a problem with argument `arg` of the C function that called it

‎src/ziglua-5.3/tests.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ test "args and errors" {
12991299

13001300
const argCheck = ziglua.wrap(struct {
13011301
fn inner(l: *Lua) i32 {
1302-
l.argCheck(true, 1, "error!");
1302+
l.argCheck(false, 1, "error!");
13031303
return 0;
13041304
}
13051305
}.inner);

‎src/ziglua-5.4/lib.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ pub const Lua = struct {
13871387
/// See https://www.lua.org/manual/5.4/manual.html#lua_argcheck
13881388
pub fn argCheck(lua: *Lua, cond: bool, arg: i32, extra_msg: [:0]const u8) void {
13891389
// translate-c failed
1390-
if (cond) lua.argError(arg, extra_msg);
1390+
if (!cond) lua.argError(arg, extra_msg);
13911391
}
13921392

13931393
/// Raises an error reporting a problem with argument `arg` of the C function that called it

‎src/ziglua-5.4/tests.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@ test "args and errors" {
13841384

13851385
const argCheck = ziglua.wrap(struct {
13861386
fn inner(l: *Lua) i32 {
1387-
l.argCheck(true, 1, "error!");
1387+
l.argCheck(false, 1, "error!");
13881388
return 0;
13891389
}
13901390
}.inner);

0 commit comments

Comments
 (0)