mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
0978566db8
My changes to how incremental compilation handles container types mean that, at least for now, it is possible for the ZIR `.main_struct_inst` of a source file to be lost (this happens if the number of top-level fields in a file changes for instance). I missed a few things which needed changing to account for this, which could lead to crashes with certain (trivial) changes---oops! Adds two new incremental test cases. They are currently disabled for wasm32-wasi-selfhosted because they both trigger a crash in the WASM backend.
102 lines
3.4 KiB
Plaintext
102 lines
3.4 KiB
Plaintext
#target=x86_64-linux-selfhosted
|
|
#target=x86_64-windows-selfhosted
|
|
#target=x86_64-linux-cbe
|
|
#target=x86_64-windows-cbe
|
|
//#target=wasm32-wasi-selfhosted
|
|
#update=initial version
|
|
#file=main.zig
|
|
const S = @This();
|
|
x: u8,
|
|
pub fn main(init: std.process.Init) !void {
|
|
var stdout_writer = std.Io.File.stdout().writerStreaming(init.io, &.{});
|
|
printFieldCount(&stdout_writer.interface) catch |err| switch (err) {
|
|
error.WriteFailed => return stdout_writer.err.?,
|
|
};
|
|
printOneField(&stdout_writer.interface) catch |err| switch (err) {
|
|
error.WriteFailed => return stdout_writer.err.?,
|
|
};
|
|
}
|
|
fn printFieldCount(w: *Writer) Writer.Error!void {
|
|
try w.print("{d} ", .{@typeInfo(S).@"struct".fields.len});
|
|
}
|
|
fn printOneField(w: *Writer) Writer.Error!void {
|
|
const val: S = .{ .x = 100 };
|
|
try w.print("{d}\n", .{val.x});
|
|
}
|
|
const std = @import("std");
|
|
const Writer = std.Io.Writer;
|
|
#expect_stdout="1 100\n"
|
|
|
|
#update=add a field
|
|
#file=main.zig
|
|
const S = @This();
|
|
x: u8,
|
|
y: u16 = 200,
|
|
pub fn main(init: std.process.Init) !void {
|
|
var stdout_writer = std.Io.File.stdout().writerStreaming(init.io, &.{});
|
|
printFieldCount(&stdout_writer.interface) catch |err| switch (err) {
|
|
error.WriteFailed => return stdout_writer.err.?,
|
|
};
|
|
printOneField(&stdout_writer.interface) catch |err| switch (err) {
|
|
error.WriteFailed => return stdout_writer.err.?,
|
|
};
|
|
}
|
|
fn printFieldCount(w: *Writer) Writer.Error!void {
|
|
try w.print("{d} ", .{@typeInfo(S).@"struct".fields.len});
|
|
}
|
|
fn printOneField(w: *Writer) Writer.Error!void {
|
|
const val: S = .{ .x = 100 };
|
|
try w.print("{d}\n", .{val.x});
|
|
}
|
|
const std = @import("std");
|
|
const Writer = std.Io.Writer;
|
|
#expect_stdout="2 100\n"
|
|
|
|
#update=remove all fields
|
|
#file=main.zig
|
|
const S = @This();
|
|
pub fn main(init: std.process.Init) !void {
|
|
var stdout_writer = std.Io.File.stdout().writerStreaming(init.io, &.{});
|
|
printFieldCount(&stdout_writer.interface) catch |err| switch (err) {
|
|
error.WriteFailed => return stdout_writer.err.?,
|
|
};
|
|
printOneField(&stdout_writer.interface) catch |err| switch (err) {
|
|
error.WriteFailed => return stdout_writer.err.?,
|
|
};
|
|
}
|
|
fn printFieldCount(w: *Writer) Writer.Error!void {
|
|
try w.print("{d} ", .{@typeInfo(S).@"struct".fields.len});
|
|
}
|
|
fn printOneField(w: *Writer) Writer.Error!void {
|
|
const val: S = .{ .x = 100 };
|
|
try w.print("{d}\n", .{val.x});
|
|
}
|
|
const std = @import("std");
|
|
const Writer = std.Io.Writer;
|
|
#expect_error=main.zig:15:24: error: no field named 'x' in struct 'main'
|
|
#expect_error=main.zig:1:1: note: struct declared here
|
|
|
|
#update=remove reference to non-existent field
|
|
#file=main.zig
|
|
const S = @This();
|
|
pub fn main(init: std.process.Init) !void {
|
|
var stdout_writer = std.Io.File.stdout().writerStreaming(init.io, &.{});
|
|
printFieldCount(&stdout_writer.interface) catch |err| switch (err) {
|
|
error.WriteFailed => return stdout_writer.err.?,
|
|
};
|
|
printOneField(&stdout_writer.interface) catch |err| switch (err) {
|
|
error.WriteFailed => return stdout_writer.err.?,
|
|
};
|
|
}
|
|
fn printFieldCount(w: *Writer) Writer.Error!void {
|
|
try w.print("{d} ", .{@typeInfo(S).@"struct".fields.len});
|
|
}
|
|
fn printOneField(w: *Writer) Writer.Error!void {
|
|
//const val: S = .{ .x = 100 };
|
|
//try w.print("{d}\n", .{val.x});
|
|
try w.writeAll("<no fields>\n");
|
|
}
|
|
const std = @import("std");
|
|
const Writer = std.Io.Writer;
|
|
#expect_stdout="0 <no fields>\n"
|