mirror of
https://github.com/ziglang/zig.git
synced 2025-12-25 07:33:08 +00:00
This change seeks to more appropriately model the way semantic analysis works by drawing a more clear line between errors emitted by analyzing a `Decl` (in future a `Cau`) and errors emitted by analyzing a runtime function. This does change a few compile errors surrounding compile logs by adding more "also here" notes. The new notes are more technically correct, but perhaps not so helpful. They're not doing enough harm for me to put extensive thought into this for now.
31 lines
803 B
Zig
31 lines
803 B
Zig
export fn foo() void {
|
|
comptime bar(12, "hi");
|
|
_ = &bar;
|
|
}
|
|
fn bar(a: i32, b: []const u8) void {
|
|
@compileLog("begin");
|
|
@compileLog("a", a, "b", b);
|
|
@compileLog("end");
|
|
}
|
|
export fn baz() void {
|
|
const S = struct { a: u32 };
|
|
@compileLog(@sizeOf(S));
|
|
}
|
|
|
|
// error
|
|
// backend=llvm
|
|
// target=native
|
|
//
|
|
// :6:5: error: found compile log statement
|
|
// :12:5: note: also here
|
|
// :6:5: note: also here
|
|
//
|
|
// Compile Log Output:
|
|
// @as(*const [5:0]u8, "begin")
|
|
// @as(*const [1:0]u8, "a"), @as(i32, 12), @as(*const [1:0]u8, "b"), @as([]const u8, "hi"[0..2])
|
|
// @as(*const [3:0]u8, "end")
|
|
// @as(comptime_int, 4)
|
|
// @as(*const [5:0]u8, "begin")
|
|
// @as(*const [1:0]u8, "a"), @as(i32, [runtime value]), @as(*const [1:0]u8, "b"), @as([]const u8, [runtime value])
|
|
// @as(*const [3:0]u8, "end")
|