Last active
August 25, 2018 15:43
-
-
Save cgag/8e1d2289cfbb3c842d61ebdddf0316f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const Food = enum { | |
Pretzel, | |
Cheese, | |
Cucumber, | |
}; | |
pub fn main() !void { | |
const alloc = &std.heap.DirectAllocator.init().allocator; | |
const s = try std.fmt.allocPrint(alloc, "food: {}\n", Food.Cheese); | |
defer alloc.free(s); | |
var stdout = try std.io.getStdOut(); | |
try stdout.write(s); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ryzen src/zig-errors » time zig build-exe main.zig && ./main | |
/home/cgag/bin/zig/build/lib/zig/std/fmt/index.zig:178:32: error: no member named 'Pretzel' in enum 'Food' | |
try formatType(@field(value, @memberName(T, field_i)), "", context, Errors, output); | |
^ | |
/home/cgag/bin/zig/build/lib/zig/std/fmt/index.zig:53:35: note: called from here | |
try formatType(args[next_arg], fmt[0..0], context, Errors, output); | |
^ | |
/home/cgag/bin/zig/build/lib/zig/std/fmt/index.zig:826:11: note: called from here | |
format(&size, error{}, countSize, fmt, args) catch |err| switch (err) {}; | |
^ | |
/home/cgag/src/zig-errors/main.zig:16:37: note: called from here | |
const s = try std.fmt.allocPrint(alloc, "food: {}\n", Food.Cheese); | |
^ | |
/home/cgag/bin/zig/build/lib/zig/std/fmt/index.zig:178:32: error: no member named 'Pretzel' in enum 'Food' | |
try formatType(@field(value, @memberName(T, field_i)), "", context, Errors, output); | |
^ | |
/home/cgag/bin/zig/build/lib/zig/std/fmt/index.zig:53:35: note: called from here | |
try formatType(args[next_arg], fmt[0..0], context, Errors, output); | |
^ | |
/home/cgag/bin/zig/build/lib/zig/std/fmt/index.zig:818:15: note: called from here | |
try format(&context, error{BufferTooSmall}, bufPrintWrite, fmt, args); | |
^ | |
/home/cgag/bin/zig/build/lib/zig/std/fmt/index.zig:828:20: note: called from here | |
return bufPrint(buf, fmt, args) catch |err| switch (err) { | |
^ | |
/home/cgag/src/zig-errors/main.zig:16:37: note: called from here | |
const s = try std.fmt.allocPrint(alloc, "food: {}\n", Food.Cheese); | |
^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment