Zig Version
0.14.0
Steps to Reproduce and Observed Output
With the following program
pub fn main() !void {
var engine = std.Random.DefaultPrng.init(0);
const eh: u8 = switch (engine.random().int(u8)) {
1 => 2,
else => 3,
} + 1;
_ = eh;
}
const std = @import("std");
The current error message is printed out
src/plus.zig:3:20: error: value with comptime-only type 'comptime_int' depends on runtime control flow
const eh: u8 = switch (engine.random().int(u8)) {
^~~~~~
src/plus.zig:3:47: note: runtime control flow here
const eh: u8 = switch (engine.random().int(u8)) {
~~~~~~~~~~~~~~~~~~~^~~~
Expected Output
I think it should suggest a fix to cast the switch expression to a runtime type, something like,
try casting the expression to a runtime int with `@as`
Zig Version
0.14.0
Steps to Reproduce and Observed Output
With the following program
The current error message is printed out
Expected Output
I think it should suggest a fix to cast the switch expression to a runtime type, something like,