Skip to content

Commit 9a6343f

Browse files
committed
Update to Zig version 0.15.0-dev.1145+3ae0ba096
Some large changes in this one. Even more on the way with Writergate and the Io revolution.
1 parent f57edef commit 9a6343f

32 files changed

Lines changed: 123 additions & 179 deletions

.github/workflows/all-debug-compile-only.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup Zig
2020
uses: mlugg/setup-zig@v1
2121
with:
22-
version: 0.15.0-dev.864+75d0ec9c0
22+
version: 0.15.0-dev.1145+3ae0ba096
2323

2424
- name: Enable all debug flags
2525
run: scripts/enable-all-debug-flags.sh

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setup Zig
1919
uses: mlugg/setup-zig@v1
2020
with:
21-
version: 0.15.0-dev.864+75d0ec9c0
21+
version: 0.15.0-dev.1145+3ae0ba096
2222

2323
- name: Run tests
2424
run: zig build test --summary all

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ You need the Zig compiler, preferably one built with the known-good version
3939
commit. You can find the source code, instructions for building, and more on the
4040
[Zig repository](https://github.com/ziglang/zig).
4141

42-
Latest Zig version known to work is [0.15.0-dev.864+75d0ec9c0](https://github.com/ziglang/zig/commit/75d0ec9c0).
42+
Latest Zig version known to work is [0.15.0-dev.1145+3ae0ba096](https://github.com/ziglang/zig/commit/3ae0ba096).
4343
Earlier and later versions may work but there are no guarantees.
4444

4545
## Building zigSelf

build.zig

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,18 @@ pub fn build(b: *std.Build) void {
3737
// Steps
3838
const exe = b.addExecutable(.{
3939
.name = "self",
40-
.root_source_file = b.path("src/main.zig"),
41-
.target = target,
42-
.optimize = optimize,
40+
.root_module = b.createModule(.{
41+
.root_source_file = b.path("src/main.zig"),
42+
.optimize = optimize,
43+
.target = target,
44+
}),
45+
// XXX: Native backend currently crashing due to Zig bug.
46+
// https://github.com/ziglang/zig/issues/24364
47+
.use_llvm = true,
4348
});
4449
exe.root_module.addImport("zigself", zigself);
4550
exe.root_module.addImport("zig-args", zig_args);
4651
exe.root_module.addImport("tracy", tracy);
47-
// NOTE: Currently forced to use LLVM backend because the native backend
48-
// segfaults (and we can't upgrade yet due to our usingnamespace
49-
// use).
50-
exe.use_llvm = true;
5152

5253
b.installArtifact(exe);
5354

@@ -62,9 +63,11 @@ pub fn build(b: *std.Build) void {
6263

6364
var test_harness_exe = b.addExecutable(.{
6465
.name = "self-test",
65-
.root_source_file = b.path("tests/harness.zig"),
66-
.target = target,
67-
.optimize = optimize,
66+
.root_module = b.createModule(.{
67+
.root_source_file = b.path("tests/harness.zig"),
68+
.target = target,
69+
.optimize = optimize,
70+
}),
6871
});
6972
test_harness_exe.root_module.addImport("zigself", zigself);
7073

build.zig.zon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
},
1212
.dependencies = .{
1313
.@"zig-args" = .{
14-
.url = "https://github.com/ikskuh/zig-args/archive/9425b94c103a031777fdd272c555ce93a7dea581.tar.gz",
15-
.hash = "args-0.0.0-CiLiqv_NAAC97fGpk9hS2K681jkiqPsWP6w3ucb_ctGH",
14+
.url = "https://github.com/ikskuh/zig-args/archive/4c305bcb45fd3c4b74b7bf7f907cf3fc12f415a2.tar.gz",
15+
.hash = "args-0.0.0-CiLiquDRAADuU_ueSmGquhHAuhDxxlfBokGj01ZdVYHt",
1616
},
1717
.tracy = .{
1818
.url = "https://github.com/wolfpld/tracy/archive/refs/tags/v0.11.1.tar.gz",

src/language/ASTPrinter.zig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ fn dedent(self: *ASTPrinter) void {
5454
}
5555

5656
fn print(self: *ASTPrinter, comptime fmt: []const u8, args: anytype) void {
57-
const writer = std.io.getStdErr().writer();
57+
var writer_buffer: [4096]u8 = undefined;
58+
var file_writer = std.fs.File.stderr().writer(&writer_buffer);
59+
const writer = &file_writer.interface;
5860
writer.writeAll(DARKGRAY) catch return;
5961

6062
var last_indent: usize = 0;
@@ -73,7 +75,7 @@ fn print(self: *ASTPrinter, comptime fmt: []const u8, args: anytype) void {
7375
writer.writeAll("╴") catch return;
7476
} else {
7577
writer.writeAll(if (!branch.concluded) "│" else " ") catch return;
76-
writer.writeByteNTimes(' ', self.indent_width - 1) catch return;
78+
writer.splatByteAll(' ', self.indent_width - 1) catch return;
7779
}
7880

7981
last_indent = branch.indent;

src/language/Location.zig

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,8 @@ line_start: usize,
1414
/// Points to the newline.
1515
line_end: usize,
1616

17-
pub fn format(
18-
location: Location,
19-
comptime fmt: []const u8,
20-
options: std.fmt.FormatOptions,
21-
writer: anytype,
22-
) !void {
23-
_ = fmt;
24-
25-
try std.fmt.formatInt(location.line, 10, .lower, options, writer);
17+
pub fn format(self: Location, writer: *std.io.Writer) !void {
18+
try writer.printInt(self.line, 10, .lower, .{});
2619
try writer.writeByte(':');
27-
try std.fmt.formatInt(location.column, 10, .lower, options, writer);
20+
try writer.printInt(self.column, 10, .lower, .{});
2821
}

src/language/LocationRange.zig

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2021-2023, sin-ack <sin-ack@protonmail.com>
1+
// Copyright (c) 2021-2025, sin-ack <sin-ack@protonmail.com>
22
//
33
// SPDX-License-Identifier: GPL-3.0-only
44

@@ -13,18 +13,13 @@ const LocationRange = @This();
1313
start: Location,
1414
end: Location,
1515

16-
pub fn format(
17-
range: LocationRange,
18-
comptime fmt: []const u8,
19-
options: std.fmt.FormatOptions,
20-
writer: anytype,
21-
) !void {
22-
try range.start.format(fmt, options, writer);
16+
pub fn format(range: LocationRange, writer: *std.io.Writer) !void {
17+
try range.start.format(writer);
2318
try writer.writeByte('-');
2419

2520
if (range.start.line != range.end.line) {
26-
try range.end.format(fmt, options, writer);
21+
try range.end.format(writer);
2722
} else {
28-
try std.fmt.formatInt(range.end.column, 10, .lower, options, writer);
23+
try writer.printInt(range.end.column, 10, .lower, .{});
2924
}
3025
}

src/language/Script.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ pub fn diagnostics(self: Script) Diagnostics {
9797
return self.parser.diagnostics;
9898
}
9999

100-
pub fn reportDiagnostics(self: Script, writer: anytype) !void {
100+
pub fn reportDiagnostics(self: Script, writer: *std.io.Writer) !void {
101101
for (self.diagnostics().diagnostics.items) |diagnostic| {
102102
const line = self.parser.buffer[diagnostic.location.line_start..diagnostic.location.line_end];
103103

104-
try writer.print("{s}:{}: {s}: {s}\n", .{ self.file_path, diagnostic.location, @tagName(diagnostic.level), diagnostic.message });
104+
try writer.print("{s}:{f}: {s}: {s}\n", .{ self.file_path, diagnostic.location, @tagName(diagnostic.level), diagnostic.message });
105105
try writer.print("{s}\n", .{line});
106-
try writer.writeByteNTimes(' ', diagnostic.location.column - 1);
106+
try writer.splatByteAll(' ', diagnostic.location.column - 1);
107107
try writer.writeAll("^\n");
108108
}
109109
}

src/main.zig

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const usage_text =
3535
;
3636

3737
fn printUsage() !void {
38-
const stderr = std.io.getStdErr();
38+
const stderr = std.fs.File.stderr();
3939
_ = try stderr.write(usage_text);
4040
}
4141

@@ -60,7 +60,7 @@ pub fn main() !u8 {
6060
}
6161

6262
if (arguments.positionals.len != 1) {
63-
const stderr = std.io.getStdErr();
63+
const stderr = std.fs.File.stderr();
6464
_ = try stderr.write("Error: Must provide exactly one argument\n");
6565
try printUsage();
6666
return 1;
@@ -73,7 +73,10 @@ pub fn main() !u8 {
7373
defer entrypoint_script.unref();
7474

7575
const did_parse_without_errors = try entrypoint_script.value.parseScript();
76-
try entrypoint_script.value.reportDiagnostics(std.io.getStdErr().writer());
76+
77+
var writer_buffer: [4096]u8 = undefined;
78+
var writer = std.fs.File.stderr().writer(&writer_buffer);
79+
try entrypoint_script.value.reportDiagnostics(&writer.interface);
7780

7881
if (arguments.options.@"dump-ast") {
7982
var printer = ASTPrinter.init(2, allocator);

0 commit comments

Comments
 (0)