Skip to content

Commit 5aef6a1

Browse files
davidgranstromnatecraddock
authored andcommitted
fix: build error for zig 0.12.0-dev.1664, replaced 'var' with 'const'
1 parent 0117fbc commit 5aef6a1

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

src/ziglua-5.1/lib.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ pub const Lua = struct {
300300
pub fn init(allocator: Allocator) !Lua {
301301
// the userdata passed to alloc needs to be a pointer with a consistent address
302302
// so we allocate an Allocator struct to hold a copy of the allocator's data
303-
var allocator_ptr = allocator.create(Allocator) catch return error.Memory;
303+
const allocator_ptr = allocator.create(Allocator) catch return error.Memory;
304304
allocator_ptr.* = allocator;
305305

306306
const state = c.lua_newstate(alloc, allocator_ptr) orelse return error.Memory;

src/ziglua-5.1/tests.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ test "dump and load" {
568568
const reader = struct {
569569
fn inner(l: *Lua, data: *anyopaque) ?[]const u8 {
570570
_ = l;
571-
var arr = ziglua.opaqueCast(std.ArrayList(u8), data);
571+
const arr = ziglua.opaqueCast(std.ArrayList(u8), data);
572572
return arr.items;
573573
}
574574
}.inner;

src/ziglua-5.2/lib.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ pub const Lua = struct {
330330
pub fn init(allocator: Allocator) !Lua {
331331
// the userdata passed to alloc needs to be a pointer with a consistent address
332332
// so we allocate an Allocator struct to hold a copy of the allocator's data
333-
var allocator_ptr = allocator.create(Allocator) catch return error.Memory;
333+
const allocator_ptr = allocator.create(Allocator) catch return error.Memory;
334334
allocator_ptr.* = allocator;
335335

336336
const state = c.lua_newstate(alloc, allocator_ptr) orelse return error.Memory;

src/ziglua-5.2/tests.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ test "dump and load" {
673673
const reader = struct {
674674
fn inner(l: *Lua, data: *anyopaque) ?[]const u8 {
675675
_ = l;
676-
var arr = ziglua.opaqueCast(std.ArrayList(u8), data);
676+
const arr = ziglua.opaqueCast(std.ArrayList(u8), data);
677677
return arr.items;
678678
}
679679
}.inner;

src/ziglua-5.3/lib.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ pub const Lua = struct {
348348
// the userdata passed to alloc needs to be a pointer with a consistent address
349349
// so we allocate an Allocator struct to hold a copy of the allocator's data
350350
// TODO: could we just pass a pointer to the init function?
351-
var allocator_ptr = allocator.create(Allocator) catch return error.Memory;
351+
const allocator_ptr = allocator.create(Allocator) catch return error.Memory;
352352
allocator_ptr.* = allocator;
353353

354354
const state = c.lua_newstate(alloc, allocator_ptr) orelse return error.Memory;

src/ziglua-5.3/tests.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ test "extra space" {
581581
var lua = try Lua.init(testing.allocator);
582582
defer lua.deinit();
583583

584-
var space: *align(1) usize = @ptrCast(lua.getExtraSpace().ptr);
584+
const space: *align(1) usize = @ptrCast(lua.getExtraSpace().ptr);
585585
space.* = 1024;
586586
// each new thread is initialized with a copy of the extra space from the main thread
587587
var thread = lua.newThread();
@@ -714,7 +714,7 @@ test "dump and load" {
714714
const reader = struct {
715715
fn inner(l: *Lua, data: *anyopaque) ?[]const u8 {
716716
_ = l;
717-
var arr = ziglua.opaqueCast(std.ArrayList(u8), data);
717+
const arr = ziglua.opaqueCast(std.ArrayList(u8), data);
718718
return arr.items;
719719
}
720720
}.inner;

src/ziglua-5.4/lib.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ pub const Lua = struct {
351351
pub fn init(allocator: Allocator) !Lua {
352352
// the userdata passed to alloc needs to be a pointer with a consistent address
353353
// so we allocate an Allocator struct to hold a copy of the allocator's data
354-
var allocator_ptr = allocator.create(Allocator) catch return error.Memory;
354+
const allocator_ptr = allocator.create(Allocator) catch return error.Memory;
355355
allocator_ptr.* = allocator;
356356

357357
const state = c.lua_newstate(alloc, allocator_ptr) orelse return error.Memory;
@@ -2122,7 +2122,7 @@ fn wrapZigWarnFn(comptime f: ZigWarnFn) CWarnFn {
21222122
return struct {
21232123
fn inner(data: ?*anyopaque, msg: [*c]const u8, to_cont: c_int) callconv(.C) void {
21242124
// warning messages emitted from Lua should be null-terminated for display
2125-
var message = std.mem.span(@as([*:0]const u8, @ptrCast(msg)));
2125+
const message = std.mem.span(@as([*:0]const u8, @ptrCast(msg)));
21262126
@call(.always_inline, f, .{ data, message, to_cont != 0 });
21272127
}
21282128
}.inner;

src/ziglua-5.4/tests.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ test "extra space" {
622622
var lua = try Lua.init(testing.allocator);
623623
defer lua.deinit();
624624

625-
var space: *align(1) usize = @ptrCast(lua.getExtraSpace().ptr);
625+
const space: *align(1) usize = @ptrCast(lua.getExtraSpace().ptr);
626626
space.* = 1024;
627627
// each new thread is initialized with a copy of the extra space from the main thread
628628
var thread = lua.newThread();
@@ -755,7 +755,7 @@ test "dump and load" {
755755
const reader = struct {
756756
fn inner(l: *Lua, data: *anyopaque) ?[]const u8 {
757757
_ = l;
758-
var arr = ziglua.opaqueCast(std.ArrayList(u8), data);
758+
const arr = ziglua.opaqueCast(std.ArrayList(u8), data);
759759
return arr.items;
760760
}
761761
}.inner;

0 commit comments

Comments
 (0)