aboutsummaryrefslogtreecommitdiff
path: root/examples/snippets/error-example.zig
blob: f35c6844cca8ee28f57a3f227d2dbfabb7811c60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// INVALID FILE — used to test the Nova issue matcher.
//
// Open this file and run it with the "Current Zig File" task (zig run).
// The compiler will report an error that the issue matcher captures:
//
//   error-example.zig:16:23: error: type 'u8' cannot represent integer value '300'
//
// This verifies that the regexp  ^(.+?):(\d+):(\d+):\s*(error|warning):\s*(.+)$
// correctly extracts file, line, column, severity, and message.

const std = @import("std");

pub fn main() void {
    // The literal 300 does not fit in a u8 (max 255). Zig catches
    // this at compile time and reports an error at this line.
    const value: u8 = 300;
    _ = value;
    _ = std.io.getStdOut();
}