mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
Merge pull request 'compiler: fix missing "local variable is never mutated" error' (#31534) from variable-not-mutated into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31534
This commit is contained in:
@@ -18,6 +18,16 @@ fn entry2() void {
|
||||
|
||||
fn foo(_: u32) void {}
|
||||
|
||||
fn entry3() void {
|
||||
var a: [1]u8 = .{0};
|
||||
_ = a[0];
|
||||
}
|
||||
|
||||
fn entry4() void {
|
||||
var s: struct { a: u8 } = .{ .a = 0 };
|
||||
_ = s.a;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:9: error: local variable is never mutated
|
||||
@@ -26,3 +36,7 @@ fn foo(_: u32) void {}
|
||||
// :9:9: note: consider using 'const'
|
||||
// :15:9: error: local variable is never mutated
|
||||
// :15:9: note: consider using 'const'
|
||||
// :22:9: error: local variable is never mutated
|
||||
// :22:9: note: consider using 'const'
|
||||
// :27:9: error: local variable is never mutated
|
||||
// :27:9: note: consider using 'const'
|
||||
|
||||
Reference in New Issue
Block a user