authorgravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2022-07-23 16:53:59+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-07-27 18:07:53+03:00
logbaafb8a491c296fbf434c8cf44d9485e8f2c729c
tree4dffed76fe1898abb975c70085e509b7f0e3a879
parent4ef7d8581085394d55f5effbb38c05a15546af1b

std.fmt: add more invalid format string errors


12 files changed, 64 insertions(+), 30 deletions(-)

lib/std/fmt.zig+44-10
...@@ -454,6 +454,10 @@ fn stripOptionalOrErrorUnionSpec(comptime fmt: []const u8) []const u8 {...@@ -454,6 +454,10 @@ fn stripOptionalOrErrorUnionSpec(comptime fmt: []const u8) []const u8 {
454 fmt[1..];454 fmt[1..];
455}455}
456456
457fn invalidFmtErr(comptime fmt: []const u8, value: anytype) void {
458 @compileError("invalid format string '" ++ fmt ++ "' for type '" ++ @typeName(@TypeOf(value)) ++ "'");
459}
460
457pub fn formatType(461pub fn formatType(
458 value: anytype,462 value: anytype,
459 comptime fmt: []const u8,463 comptime fmt: []const u8,
...@@ -482,9 +486,11 @@ pub fn formatType(...@@ -482,9 +486,11 @@ pub fn formatType(
482 return formatValue(value, actual_fmt, options, writer);486 return formatValue(value, actual_fmt, options, writer);
483 },487 },
484 .Void => {488 .Void => {
489 if (actual_fmt.len != 0) invalidFmtErr(fmt, value);
485 return formatBuf("void", options, writer);490 return formatBuf("void", options, writer);
486 },491 },
487 .Bool => {492 .Bool => {
493 if (actual_fmt.len != 0) invalidFmtErr(fmt, value);
488 return formatBuf(if (value) "true" else "false", options, writer);494 return formatBuf(if (value) "true" else "false", options, writer);
489 },495 },
490 .Optional => {496 .Optional => {
...@@ -504,16 +510,18 @@ pub fn formatType(...@@ -504,16 +510,18 @@ pub fn formatType(
504 if (value) |payload| {510 if (value) |payload| {
505 return formatType(payload, remaining_fmt, options, writer, max_depth);511 return formatType(payload, remaining_fmt, options, writer, max_depth);
506 } else |err| {512 } else |err| {
507 return formatType(err, remaining_fmt, options, writer, max_depth);513 return formatType(err, "", options, writer, max_depth);
508 }514 }
509 },515 },
510 .ErrorSet => {516 .ErrorSet => {
517 if (actual_fmt.len != 0) invalidFmtErr(fmt, value);
511 try writer.writeAll("error.");518 try writer.writeAll("error.");
512 return writer.writeAll(@errorName(value));519 return writer.writeAll(@errorName(value));
513 },520 },
514 .Enum => |enumInfo| {521 .Enum => |enumInfo| {
515 try writer.writeAll(@typeName(T));522 try writer.writeAll(@typeName(T));
516 if (enumInfo.is_exhaustive) {523 if (enumInfo.is_exhaustive) {
524 if (actual_fmt.len != 0) invalidFmtErr(fmt, value);
517 try writer.writeAll(".");525 try writer.writeAll(".");
518 try writer.writeAll(@tagName(value));526 try writer.writeAll(@tagName(value));
519 return;527 return;
...@@ -534,6 +542,7 @@ pub fn formatType(...@@ -534,6 +542,7 @@ pub fn formatType(
534 try writer.writeAll(")");542 try writer.writeAll(")");
535 },543 },
536 .Union => |info| {544 .Union => |info| {
545 if (actual_fmt.len != 0) invalidFmtErr(fmt, value);
537 try writer.writeAll(@typeName(T));546 try writer.writeAll(@typeName(T));
538 if (max_depth == 0) {547 if (max_depth == 0) {
539 return writer.writeAll("{ ... }");548 return writer.writeAll("{ ... }");
...@@ -553,6 +562,7 @@ pub fn formatType(...@@ -553,6 +562,7 @@ pub fn formatType(
553 }562 }
554 },563 },
555 .Struct => |info| {564 .Struct => |info| {
565 if (actual_fmt.len != 0) invalidFmtErr(fmt, value);
556 if (info.is_tuple) {566 if (info.is_tuple) {
557 // Skip the type and field names when formatting tuples.567 // Skip the type and field names when formatting tuples.
558 if (max_depth == 0) {568 if (max_depth == 0) {
...@@ -608,7 +618,7 @@ pub fn formatType(...@@ -608,7 +618,7 @@ pub fn formatType(
608 }618 }
609 return;619 return;
610 }620 }
611 @compileError("unknown format string: '" ++ actual_fmt ++ "' for type '" ++ @typeName(T) ++ "'");621 invalidFmtErr(fmt, value);
612 },622 },
613 .Enum, .Union, .Struct => {623 .Enum, .Union, .Struct => {
614 return formatType(value.*, actual_fmt, options, writer, max_depth);624 return formatType(value.*, actual_fmt, options, writer, max_depth);
...@@ -630,7 +640,7 @@ pub fn formatType(...@@ -630,7 +640,7 @@ pub fn formatType(
630 else => {},640 else => {},
631 }641 }
632 }642 }
633 @compileError("unknown format string: '" ++ actual_fmt ++ "' for type '" ++ @typeName(T) ++ "'");643 invalidFmtErr(fmt, value);
634 },644 },
635 .Slice => {645 .Slice => {
636 if (actual_fmt.len == 0)646 if (actual_fmt.len == 0)
...@@ -693,14 +703,22 @@ pub fn formatType(...@@ -693,14 +703,22 @@ pub fn formatType(
693 try writer.writeAll(" }");703 try writer.writeAll(" }");
694 },704 },
695 .Fn => {705 .Fn => {
706 if (actual_fmt.len != 0) invalidFmtErr(fmt, value);
696 return format(writer, "{s}@{x}", .{ @typeName(T), @ptrToInt(value) });707 return format(writer, "{s}@{x}", .{ @typeName(T), @ptrToInt(value) });
697 },708 },
698 .Type => return formatBuf(@typeName(value), options, writer),709 .Type => {
710 if (actual_fmt.len != 0) invalidFmtErr(fmt, value);
711 return formatBuf(@typeName(value), options, writer);
712 },
699 .EnumLiteral => {713 .EnumLiteral => {
714 if (actual_fmt.len != 0) invalidFmtErr(fmt, value);
700 const buffer = [_]u8{'.'} ++ @tagName(value);715 const buffer = [_]u8{'.'} ++ @tagName(value);
701 return formatBuf(buffer, options, writer);716 return formatBuf(buffer, options, writer);
702 },717 },
703 .Null => return formatBuf("null", options, writer),718 .Null => {
719 if (actual_fmt.len != 0) invalidFmtErr(fmt, value);
720 return formatBuf("null", options, writer);
721 },
704 else => @compileError("unable to format type '" ++ @typeName(T) ++ "'"),722 else => @compileError("unable to format type '" ++ @typeName(T) ++ "'"),
705 }723 }
706}724}
...@@ -768,7 +786,7 @@ pub fn formatIntValue(...@@ -768,7 +786,7 @@ pub fn formatIntValue(
768 radix = 8;786 radix = 8;
769 case = .lower;787 case = .lower;
770 } else {788 } else {
771 @compileError("unsupported format string '" ++ fmt ++ "' for type '" ++ @typeName(@TypeOf(value)) ++ "'");789 invalidFmtErr(fmt, value);
772 }790 }
773791
774 return formatInt(int_value, radix, case, options, writer);792 return formatInt(int_value, radix, case, options, writer);
...@@ -797,7 +815,7 @@ fn formatFloatValue(...@@ -797,7 +815,7 @@ fn formatFloatValue(
797 error.NoSpaceLeft => unreachable,815 error.NoSpaceLeft => unreachable,
798 };816 };
799 } else {817 } else {
800 @compileError("unsupported format string '" ++ fmt ++ "' for type '" ++ @typeName(@TypeOf(value)) ++ "'");818 invalidFmtErr(fmt, value);
801 }819 }
802820
803 return formatBuf(buf_stream.getWritten(), options, writer);821 return formatBuf(buf_stream.getWritten(), options, writer);
...@@ -2000,6 +2018,12 @@ test "optional" {...@@ -2000,6 +2018,12 @@ test "optional" {
2000 {2018 {
2001 const value: ?i32 = 1234;2019 const value: ?i32 = 1234;
2002 try expectFmt("optional: 1234\n", "optional: {?}\n", .{value});2020 try expectFmt("optional: 1234\n", "optional: {?}\n", .{value});
2021 try expectFmt("optional: 1234\n", "optional: {?d}\n", .{value});
2022 try expectFmt("optional: 4d2\n", "optional: {?x}\n", .{value});
2023 }
2024 {
2025 const value: ?[]const u8 = "string";
2026 try expectFmt("optional: string\n", "optional: {?s}\n", .{value});
2003 }2027 }
2004 {2028 {
2005 const value: ?i32 = null;2029 const value: ?i32 = null;
...@@ -2015,6 +2039,12 @@ test "error" {...@@ -2015,6 +2039,12 @@ test "error" {
2015 {2039 {
2016 const value: anyerror!i32 = 1234;2040 const value: anyerror!i32 = 1234;
2017 try expectFmt("error union: 1234\n", "error union: {!}\n", .{value});2041 try expectFmt("error union: 1234\n", "error union: {!}\n", .{value});
2042 try expectFmt("error union: 1234\n", "error union: {!d}\n", .{value});
2043 try expectFmt("error union: 4d2\n", "error union: {!x}\n", .{value});
2044 }
2045 {
2046 const value: anyerror![]const u8 = "string";
2047 try expectFmt("error union: string\n", "error union: {!s}\n", .{value});
2018 }2048 }
2019 {2049 {
2020 const value: anyerror!i32 = error.InvalidChar;2050 const value: anyerror!i32 = error.InvalidChar;
...@@ -2209,6 +2239,10 @@ test "struct" {...@@ -2209,6 +2239,10 @@ test "struct" {
2209}2239}
22102240
2211test "enum" {2241test "enum" {
2242 if (builtin.zig_backend == .stage1) {
2243 // stage1 starts the typename with 'std' which might also be desireable for stage2
2244 return error.SkipZigTest;
2245 }
2212 const Enum = enum {2246 const Enum = enum {
2213 One,2247 One,
2214 Two,2248 Two,
...@@ -2216,8 +2250,8 @@ test "enum" {...@@ -2216,8 +2250,8 @@ test "enum" {
2216 const value = Enum.Two;2250 const value = Enum.Two;
2217 try expectFmt("enum: Enum.Two\n", "enum: {}\n", .{value});2251 try expectFmt("enum: Enum.Two\n", "enum: {}\n", .{value});
2218 try expectFmt("enum: Enum.Two\n", "enum: {}\n", .{&value});2252 try expectFmt("enum: Enum.Two\n", "enum: {}\n", .{&value});
2219 try expectFmt("enum: Enum.One\n", "enum: {x}\n", .{Enum.One});2253 try expectFmt("enum: Enum.One\n", "enum: {}\n", .{Enum.One});
2220 try expectFmt("enum: Enum.Two\n", "enum: {X}\n", .{Enum.Two});2254 try expectFmt("enum: Enum.Two\n", "enum: {}\n", .{Enum.Two});
22212255
2222 // test very large enum to verify ct branch quota is large enough2256 // test very large enum to verify ct branch quota is large enough
2223 try expectFmt("enum: os.windows.win32error.Win32Error.INVALID_FUNCTION\n", "enum: {}\n", .{std.os.windows.Win32Error.INVALID_FUNCTION});2257 try expectFmt("enum: os.windows.win32error.Win32Error.INVALID_FUNCTION\n", "enum: {}\n", .{std.os.windows.Win32Error.INVALID_FUNCTION});
...@@ -2675,7 +2709,7 @@ test "vector" {...@@ -2675,7 +2709,7 @@ test "vector" {
2675}2709}
26762710
2677test "enum-literal" {2711test "enum-literal" {
2678 try expectFmt(".hello_world", "{s}", .{.hello_world});2712 try expectFmt(".hello_world", "{}", .{.hello_world});
2679}2713}
26802714
2681test "padding" {2715test "padding" {
src/Sema.zig+1-1
...@@ -2173,7 +2173,7 @@ fn coerceResultPtr(...@@ -2173,7 +2173,7 @@ fn coerceResultPtr(
2173 },2173 },
2174 else => {2174 else => {
2175 if (std.debug.runtime_safety) {2175 if (std.debug.runtime_safety) {
2176 std.debug.panic("unexpected AIR tag for coerce_result_ptr: {s}", .{2176 std.debug.panic("unexpected AIR tag for coerce_result_ptr: {}", .{
2177 air_tags[trash_inst],2177 air_tags[trash_inst],
2178 });2178 });
2179 } else {2179 } else {
src/arch/sparc64/bits.zig+2-2
...@@ -1582,8 +1582,8 @@ test "Serialize formats" {...@@ -1582,8 +1582,8 @@ test "Serialize formats" {
1582 for (testcases) |case| {1582 for (testcases) |case| {
1583 const actual = case.inst.toU32();1583 const actual = case.inst.toU32();
1584 testing.expectEqual(case.expected, actual) catch |err| {1584 testing.expectEqual(case.expected, actual) catch |err| {
1585 std.debug.print("error: {x}\n", .{err});1585 std.debug.print("error: {}\n", .{err});
1586 std.debug.print("case: {x}\n", .{case});1586 std.debug.print("case: {}\n", .{case});
1587 return err;1587 return err;
1588 };1588 };
1589 }1589 }
src/arch/wasm/CodeGen.zig+3-3
...@@ -1773,7 +1773,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallOptions....@@ -1773,7 +1773,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallOptions.
1773 } else if (func_val.castTag(.decl_ref)) |decl_ref| {1773 } else if (func_val.castTag(.decl_ref)) |decl_ref| {
1774 break :blk module.declPtr(decl_ref.data);1774 break :blk module.declPtr(decl_ref.data);
1775 }1775 }
1776 return self.fail("Expected a function, but instead found type '{s}'", .{func_val.tag()});1776 return self.fail("Expected a function, but instead found type '{}'", .{func_val.tag()});
1777 };1777 };
17781778
1779 const sret = if (first_param_sret) blk: {1779 const sret = if (first_param_sret) blk: {
...@@ -2365,7 +2365,7 @@ fn lowerConstant(self: *Self, val: Value, ty: Type) InnerError!WValue {...@@ -2365,7 +2365,7 @@ fn lowerConstant(self: *Self, val: Value, ty: Type) InnerError!WValue {
2365 },2365 },
2366 .int_u64, .one => return WValue{ .imm32 = @intCast(u32, val.toUnsignedInt(target)) },2366 .int_u64, .one => return WValue{ .imm32 = @intCast(u32, val.toUnsignedInt(target)) },
2367 .zero, .null_value => return WValue{ .imm32 = 0 },2367 .zero, .null_value => return WValue{ .imm32 = 0 },
2368 else => return self.fail("Wasm TODO: lowerConstant for other const pointer tag {s}", .{val.tag()}),2368 else => return self.fail("Wasm TODO: lowerConstant for other const pointer tag {}", .{val.tag()}),
2369 },2369 },
2370 .Enum => {2370 .Enum => {
2371 if (val.castTag(.enum_field_index)) |field_index| {2371 if (val.castTag(.enum_field_index)) |field_index| {
...@@ -2421,7 +2421,7 @@ fn lowerConstant(self: *Self, val: Value, ty: Type) InnerError!WValue {...@@ -2421,7 +2421,7 @@ fn lowerConstant(self: *Self, val: Value, ty: Type) InnerError!WValue {
2421 const is_pl = val.tag() == .opt_payload;2421 const is_pl = val.tag() == .opt_payload;
2422 return WValue{ .imm32 = if (is_pl) @as(u32, 1) else 0 };2422 return WValue{ .imm32 = if (is_pl) @as(u32, 1) else 0 };
2423 },2423 },
2424 else => |zig_type| return self.fail("Wasm TODO: LowerConstant for zigTypeTag {s}", .{zig_type}),2424 else => |zig_type| return self.fail("Wasm TODO: LowerConstant for zigTypeTag {}", .{zig_type}),
2425 }2425 }
2426}2426}
24272427
src/arch/x86_64/Emit.zig+1-1
...@@ -202,7 +202,7 @@ pub fn lowerMir(emit: *Emit) InnerError!void {...@@ -202,7 +202,7 @@ pub fn lowerMir(emit: *Emit) InnerError!void {
202 .pop_regs => try emit.mirPushPopRegisterList(.pop, inst),202 .pop_regs => try emit.mirPushPopRegisterList(.pop, inst),
203203
204 else => {204 else => {
205 return emit.fail("Implement MIR->Emit lowering for x86_64 for pseudo-inst: {s}", .{tag});205 return emit.fail("Implement MIR->Emit lowering for x86_64 for pseudo-inst: {}", .{tag});
206 },206 },
207 }207 }
208 }208 }
src/link/MachO/Atom.zig+3-3
...@@ -246,7 +246,7 @@ pub fn parseRelocs(self: *Atom, relocs: []const macho.relocation_info, context:...@@ -246,7 +246,7 @@ pub fn parseRelocs(self: *Atom, relocs: []const macho.relocation_info, context:
246 else => {246 else => {
247 log.err("unexpected relocation type after ARM64_RELOC_ADDEND", .{});247 log.err("unexpected relocation type after ARM64_RELOC_ADDEND", .{});
248 log.err(" expected ARM64_RELOC_PAGE21 or ARM64_RELOC_PAGEOFF12", .{});248 log.err(" expected ARM64_RELOC_PAGE21 or ARM64_RELOC_PAGEOFF12", .{});
249 log.err(" found {s}", .{next});249 log.err(" found {}", .{next});
250 return error.UnexpectedRelocationType;250 return error.UnexpectedRelocationType;
251 },251 },
252 }252 }
...@@ -285,7 +285,7 @@ pub fn parseRelocs(self: *Atom, relocs: []const macho.relocation_info, context:...@@ -285,7 +285,7 @@ pub fn parseRelocs(self: *Atom, relocs: []const macho.relocation_info, context:
285 else => {285 else => {
286 log.err("unexpected relocation type after ARM64_RELOC_ADDEND", .{});286 log.err("unexpected relocation type after ARM64_RELOC_ADDEND", .{});
287 log.err(" expected ARM64_RELOC_UNSIGNED", .{});287 log.err(" expected ARM64_RELOC_UNSIGNED", .{});
288 log.err(" found {s}", .{@intToEnum(macho.reloc_type_arm64, relocs[i + 1].r_type)});288 log.err(" found {}", .{@intToEnum(macho.reloc_type_arm64, relocs[i + 1].r_type)});
289 return error.UnexpectedRelocationType;289 return error.UnexpectedRelocationType;
290 },290 },
291 },291 },
...@@ -294,7 +294,7 @@ pub fn parseRelocs(self: *Atom, relocs: []const macho.relocation_info, context:...@@ -294,7 +294,7 @@ pub fn parseRelocs(self: *Atom, relocs: []const macho.relocation_info, context:
294 else => {294 else => {
295 log.err("unexpected relocation type after X86_64_RELOC_ADDEND", .{});295 log.err("unexpected relocation type after X86_64_RELOC_ADDEND", .{});
296 log.err(" expected X86_64_RELOC_UNSIGNED", .{});296 log.err(" expected X86_64_RELOC_UNSIGNED", .{});
297 log.err(" found {s}", .{@intToEnum(macho.reloc_type_x86_64, relocs[i + 1].r_type)});297 log.err(" found {}", .{@intToEnum(macho.reloc_type_x86_64, relocs[i + 1].r_type)});
298 return error.UnexpectedRelocationType;298 return error.UnexpectedRelocationType;
299 },299 },
300 },300 },
src/link/MachO/Dylib.zig+2-2
...@@ -167,7 +167,7 @@ pub fn parse(...@@ -167,7 +167,7 @@ pub fn parse(
167 const this_arch: std.Target.Cpu.Arch = try fat.decodeArch(self.header.?.cputype, true);167 const this_arch: std.Target.Cpu.Arch = try fat.decodeArch(self.header.?.cputype, true);
168168
169 if (this_arch != cpu_arch) {169 if (this_arch != cpu_arch) {
170 log.err("mismatched cpu architecture: expected {s}, found {s}", .{ cpu_arch, this_arch });170 log.err("mismatched cpu architecture: expected {}, found {}", .{ cpu_arch, this_arch });
171 return error.MismatchedCpuArchitecture;171 return error.MismatchedCpuArchitecture;
172 }172 }
173173
...@@ -208,7 +208,7 @@ fn readLoadCommands(...@@ -208,7 +208,7 @@ fn readLoadCommands(
208 }208 }
209 },209 },
210 else => {210 else => {
211 log.debug("Unknown load command detected: 0x{x}.", .{cmd.cmd()});211 log.debug("Unknown load command detected: 0x{x}.", .{@enumToInt(cmd.cmd())});
212 },212 },
213 }213 }
214 self.load_commands.appendAssumeCapacity(cmd);214 self.load_commands.appendAssumeCapacity(cmd);
src/link/MachO/Object.zig+2-2
...@@ -110,7 +110,7 @@ pub fn parse(self: *Object, allocator: Allocator, cpu_arch: std.Target.Cpu.Arch)...@@ -110,7 +110,7 @@ pub fn parse(self: *Object, allocator: Allocator, cpu_arch: std.Target.Cpu.Arch)
110 },110 },
111 };111 };
112 if (this_arch != cpu_arch) {112 if (this_arch != cpu_arch) {
113 log.err("mismatched cpu architecture: expected {s}, found {s}", .{ cpu_arch, this_arch });113 log.err("mismatched cpu architecture: expected {}, found {}", .{ cpu_arch, this_arch });
114 return error.MismatchedCpuArchitecture;114 return error.MismatchedCpuArchitecture;
115 }115 }
116116
...@@ -171,7 +171,7 @@ pub fn parse(self: *Object, allocator: Allocator, cpu_arch: std.Target.Cpu.Arch)...@@ -171,7 +171,7 @@ pub fn parse(self: *Object, allocator: Allocator, cpu_arch: std.Target.Cpu.Arch)
171 cmd.linkedit_data.dataoff += file_offset;171 cmd.linkedit_data.dataoff += file_offset;
172 },172 },
173 else => {173 else => {
174 log.debug("Unknown load command detected: 0x{x}.", .{cmd.cmd()});174 log.debug("Unknown load command detected: 0x{x}.", .{@enumToInt(cmd.cmd())});
175 },175 },
176 }176 }
177 self.load_commands.appendAssumeCapacity(cmd);177 self.load_commands.appendAssumeCapacity(cmd);
src/link/MachO/fat.zig+1-1
...@@ -46,7 +46,7 @@ pub fn getLibraryOffset(reader: anytype, cpu_arch: std.Target.Cpu.Arch) !u64 {...@@ -46,7 +46,7 @@ pub fn getLibraryOffset(reader: anytype, cpu_arch: std.Target.Cpu.Arch) !u64 {
46 return fat_arch.offset;46 return fat_arch.offset;
47 }47 }
48 } else {48 } else {
49 log.err("Could not find matching cpu architecture in fat library: expected {s}", .{cpu_arch});49 log.err("Could not find matching cpu architecture in fat library: expected {}", .{cpu_arch});
50 return error.MismatchedCpuArchitecture;50 return error.MismatchedCpuArchitecture;
51 }51 }
52}52}
src/main.zig+3-3
...@@ -4076,12 +4076,12 @@ pub fn cmdFmt(gpa: Allocator, arena: Allocator, args: []const []const u8) !void...@@ -4076,12 +4076,12 @@ pub fn cmdFmt(gpa: Allocator, arena: Allocator, args: []const []const u8) !void
40764076
4077 const stdin = io.getStdIn();4077 const stdin = io.getStdIn();
4078 const source_code = readSourceFileToEndAlloc(gpa, &stdin, null) catch |err| {4078 const source_code = readSourceFileToEndAlloc(gpa, &stdin, null) catch |err| {
4079 fatal("unable to read stdin: {s}", .{err});4079 fatal("unable to read stdin: {}", .{err});
4080 };4080 };
4081 defer gpa.free(source_code);4081 defer gpa.free(source_code);
40824082
4083 var tree = std.zig.parse(gpa, source_code) catch |err| {4083 var tree = std.zig.parse(gpa, source_code) catch |err| {
4084 fatal("error parsing stdin: {s}", .{err});4084 fatal("error parsing stdin: {}", .{err});
4085 };4085 };
4086 defer tree.deinit(gpa);4086 defer tree.deinit(gpa);
40874087
...@@ -5011,7 +5011,7 @@ pub fn cmdAstCheck(...@@ -5011,7 +5011,7 @@ pub fn cmdAstCheck(
5011 } else {5011 } else {
5012 const stdin = io.getStdIn();5012 const stdin = io.getStdIn();
5013 const source = readSourceFileToEndAlloc(arena, &stdin, null) catch |err| {5013 const source = readSourceFileToEndAlloc(arena, &stdin, null) catch |err| {
5014 fatal("unable to read stdin: {s}", .{err});5014 fatal("unable to read stdin: {}", .{err});
5015 };5015 };
5016 file.sub_file_path = "<stdin>";5016 file.sub_file_path = "<stdin>";
5017 file.source = source;5017 file.source = source;
src/print_zir.zig+1-1
...@@ -551,7 +551,7 @@ const Writer = struct {...@@ -551,7 +551,7 @@ const Writer = struct {
551 fn writeElemTypeIndex(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {551 fn writeElemTypeIndex(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
552 const inst_data = self.code.instructions.items(.data)[inst].bin;552 const inst_data = self.code.instructions.items(.data)[inst].bin;
553 try self.writeInstRef(stream, inst_data.lhs);553 try self.writeInstRef(stream, inst_data.lhs);
554 try stream.print(", {d})", .{inst_data.rhs});554 try stream.print(", {d})", .{@enumToInt(inst_data.rhs)});
555 }555 }
556556
557 fn writeUnNode(557 fn writeUnNode(
src/translate_c.zig+1-1
...@@ -3279,7 +3279,7 @@ fn transConstantExpr(c: *Context, scope: *Scope, expr: *const clang.Expr, used:...@@ -3279,7 +3279,7 @@ fn transConstantExpr(c: *Context, scope: *Scope, expr: *const clang.Expr, used:
3279 return maybeSuppressResult(c, scope, used, as_node);3279 return maybeSuppressResult(c, scope, used, as_node);
3280 },3280 },
3281 else => |kind| {3281 else => |kind| {
3282 return fail(c, error.UnsupportedTranslation, expr.getBeginLoc(), "unsupported constant expression kind '{s}'", .{kind});3282 return fail(c, error.UnsupportedTranslation, expr.getBeginLoc(), "unsupported constant expression kind '{}'", .{kind});
3283 },3283 },
3284 }3284 }
3285}3285}