In the file ZigExamples/comptime/comptime_arg_runtime_error.zig, there is an error in line 17. If we look at lines 15-20
var buffer: [5]u8 = .{ 0, 0, 0, 0, 0 };
_ = try stdout.write("Please write a 4-digit integer number\n");
_ = try stdin.takeDelimiterExclusive('\n');
try stdout.print("Input: {s}", .{buffer});
const n: u32 = try std.fmt.parseInt(u32, buffer[0 .. buffer.len - 1], 10);
Here, "buffer" is defined on line 15 and it's referenced again in lines 19 and 20 but it is never updated to store the user input.
So, as we can expect when I run the file with "zig run", I get the following error message:
comptime-function-args.zig:15:9: error: local variable is never mutated
In the file ZigExamples/comptime/comptime_arg_runtime_error.zig, there is an error in line 17. If we look at lines 15-20
var buffer: [5]u8 = .{ 0, 0, 0, 0, 0 };
_ = try stdout.write("Please write a 4-digit integer number\n");
_ = try stdin.takeDelimiterExclusive('\n');
try stdout.print("Input: {s}", .{buffer});
const n: u32 = try std.fmt.parseInt(u32, buffer[0 .. buffer.len - 1], 10);
Here, "buffer" is defined on line 15 and it's referenced again in lines 19 and 20 but it is never updated to store the user input.
So, as we can expect when I run the file with "zig run", I get the following error message:
comptime-function-args.zig:15:9: error: local variable is never mutated