Skip to content

Commit c8d319e

Browse files
committed
Fix guided tour for new Table API and strengthen CLAUDE.md guidelines
Update guided tour example to work with new Table.get() API that returns T instead of ?T. Remove all optional unwrapping (.?) since get() now throws Error.KeyNotFound instead. Also strengthen CLAUDE.md git workflow guidelines to absolutely forbid any AI attribution or generation notices in commits and pull requests.
1 parent 36d1dd3 commit c8d319e

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

examples/guided_tour.zig

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ pub fn main() !void {
181181
const float_val = try globals.get("float_var", f64);
182182
const bool_val = try globals.get("bool_var", bool);
183183

184-
print("string_var: {s}\n", .{str_val.?});
185-
print("int_var: {}\n", .{int_val.?});
186-
print("float_var: {d:.2}\n", .{float_val.?});
187-
print("bool_var: {}\n", .{bool_val.?});
184+
print("string_var: {s}\n", .{str_val});
185+
print("int_var: {}\n", .{int_val});
186+
print("float_var: {d:.2}\n", .{float_val});
187+
print("bool_var: {}\n", .{bool_val});
188188
}
189189

190190
// Evaluating Lua code
@@ -204,7 +204,7 @@ pub fn main() !void {
204204
_ = try lua.eval("global = 'foo' .. 'bar'", .{}, void);
205205
const globals = lua.globals();
206206
const concat = try globals.get("global", []const u8);
207-
print("'foo' .. 'bar' = {s}\n", .{concat.?});
207+
print("'foo' .. 'bar' = {s}\n", .{concat});
208208

209209
// Multiple return values as tuples
210210
const tuple_result = try lua.eval("return 10, 2.5, false", .{}, struct { i32, f64, bool });
@@ -264,7 +264,7 @@ pub fn main() !void {
264264

265265
// Read back values
266266
const v = try map_table.get("two", i32);
267-
print("map_table['two'] = {}\n", .{v.?});
267+
print("map_table['two'] = {}\n", .{v});
268268

269269
// Pass tables to Lua
270270
const globals = lua.globals();
@@ -478,7 +478,7 @@ pub fn main() !void {
478478
// Retrieve individual fields from table structures
479479
const x_coord = try point_table.get("x", f32);
480480
const y_coord = try point_table.get("y", f32);
481-
print("Retrieved point coordinates: x={d:.1}, y={d:.1}\n", .{ x_coord.?, y_coord.? });
481+
print("Retrieved point coordinates: x={d:.1}, y={d:.1}\n", .{ x_coord, y_coord });
482482
}
483483

484484
// Garbage collection control
@@ -600,21 +600,21 @@ pub fn main() !void {
600600

601601
const thread = lua.createThread();
602602
const func = try thread.globals().get("accumulator", luaz.Lua.Function);
603-
defer func.?.deinit();
603+
defer func.deinit();
604604

605605
// Start the coroutine - yields initial sum (0)
606-
const result1 = try func.?.call(.{}, i32);
606+
const result1 = try func.call(.{}, i32);
607607
print("Start: sum={}\n", .{result1.yield.?});
608608

609609
// Continue with values to accumulate
610-
const result2 = try func.?.call(.{10}, i32);
610+
const result2 = try func.call(.{10}, i32);
611611
print("Add 10: sum={}\n", .{result2.yield.?});
612612

613-
const result3 = try func.?.call(.{25}, i32);
613+
const result3 = try func.call(.{25}, i32);
614614
print("Add 25: sum={}\n", .{result3.yield.?});
615615

616616
// Send nil to finish
617-
const final_result = try func.?.call(.{@as(?i32, null)}, i32);
617+
const final_result = try func.call(.{@as(?i32, null)}, i32);
618618
print("Final: sum={}\n", .{final_result.ok.?});
619619
}
620620

@@ -634,7 +634,7 @@ pub fn main() !void {
634634
const globals = lua.globals();
635635
try globals.set("message", &buf);
636636
const message = try globals.get("message", []const u8);
637-
print("Built string: {s}\n", .{message.?});
637+
print("Built string: {s}\n", .{message});
638638

639639
// Return StrBuf from Zig functions
640640
const formatMessage = struct {
@@ -796,10 +796,10 @@ pub fn main() !void {
796796

797797
// Get the function and set a breakpoint
798798
const func = try lua.globals().get("debugTarget", luaz.Lua.Function);
799-
defer func.?.deinit();
799+
defer func.deinit();
800800

801801
print("Setting breakpoint on line 3...\n", .{});
802-
const actual_line = try func.?.setBreakpoint(3, true);
802+
const actual_line = try func.setBreakpoint(3, true);
803803
print("Breakpoint set on line {}\n", .{actual_line});
804804

805805
// Create a thread for debugging (avoids C-call boundary issues)
@@ -808,11 +808,11 @@ pub fn main() !void {
808808

809809
// Get the function in the thread context
810810
const thread_func = try debug_thread.globals().get("debugTarget", luaz.Lua.Function);
811-
defer thread_func.?.deinit();
811+
defer thread_func.deinit();
812812

813813
// Call the function - this should hit the breakpoint
814814
print("Calling debugTarget(5, 7) in thread...\n", .{});
815-
const debug_result = try thread_func.?.call(.{ 5, 7 }, struct { i32, i32 });
815+
const debug_result = try thread_func.call(.{ 5, 7 }, struct { i32, i32 });
816816
if (debug_result.ok) |result| {
817817
print("Function completed: sum={}, product={}\n", .{ result[0], result[1] });
818818
}

0 commit comments

Comments
 (0)