From 88b104a9dfd1cd7aad826447e57c64b4619ea148 Mon Sep 17 00:00:00 2001 From: Tau Date: Sat, 13 Jul 2024 23:26:36 +0200 Subject: [PATCH] Fix #12829 --- lib/std/builtin.zig | 2 +- lib/std/zig/Parse.zig | 4 ++-- .../@intFromFloat cannot fit - negative out of range.zig | 2 +- .../@intFromFloat cannot fit - negative to unsigned.zig | 2 +- .../@intFromFloat cannot fit - positive out of range.zig | 2 +- test/compile_errors.zig | 2 -- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index 3026911d3f97..9f4ca3edbec7 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -904,7 +904,7 @@ pub const panic_messages = struct { pub const divide_by_zero = "division by zero"; pub const exact_division_remainder = "exact division produced remainder"; pub const inactive_union_field = "access of inactive union field"; - pub const integer_part_out_of_bounds = "integer part of floating point value out of bounds"; + pub const integer_part_out_of_bounds = "integer part of floating point value out of bounds or not finite"; pub const corrupt_switch = "switch on corrupt value"; pub const shift_rhs_too_big = "shift amount is greater than the type size"; pub const invalid_enum_value = "invalid enum value"; diff --git a/lib/std/zig/Parse.zig b/lib/std/zig/Parse.zig index 73f258028438..68e891b50b1d 100644 --- a/lib/std/zig/Parse.zig +++ b/lib/std/zig/Parse.zig @@ -214,12 +214,12 @@ pub fn findUnmatchedParen(gpa: Allocator, token_tags: []const Token.Tag) !?Token for (token_tags, 0..) |t, i| { switch (t) { - .l_paren, .l_brace, .l_bracket => try stack.append(.{.tag = t, .idx = @intCast(i)}), + .l_paren, .l_brace, .l_bracket => try stack.append(.{ .tag = t, .idx = @intCast(i) }), .r_paren, .r_brace, .r_bracket => { if (stack.items.len == 0 or !parenMatch(stack.pop().tag, t)) return @intCast(i); }, - else => {} + else => {}, } } if (stack.items.len > 0) diff --git a/test/cases/safety/@intFromFloat cannot fit - negative out of range.zig b/test/cases/safety/@intFromFloat cannot fit - negative out of range.zig index a5a8d831b337..ad2489bea09b 100644 --- a/test/cases/safety/@intFromFloat cannot fit - negative out of range.zig +++ b/test/cases/safety/@intFromFloat cannot fit - negative out of range.zig @@ -2,7 +2,7 @@ const std = @import("std"); pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer part of floating point value out of bounds")) { + if (std.mem.eql(u8, message, "integer part of floating point value out of bounds or not finite")) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/@intFromFloat cannot fit - negative to unsigned.zig b/test/cases/safety/@intFromFloat cannot fit - negative to unsigned.zig index 1bf1a667659f..377d32549fae 100644 --- a/test/cases/safety/@intFromFloat cannot fit - negative to unsigned.zig +++ b/test/cases/safety/@intFromFloat cannot fit - negative to unsigned.zig @@ -2,7 +2,7 @@ const std = @import("std"); pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer part of floating point value out of bounds")) { + if (std.mem.eql(u8, message, "integer part of floating point value out of bounds or not finite")) { std.process.exit(0); } std.process.exit(1); diff --git a/test/cases/safety/@intFromFloat cannot fit - positive out of range.zig b/test/cases/safety/@intFromFloat cannot fit - positive out of range.zig index 15a9fa7ad188..e58cf36e2929 100644 --- a/test/cases/safety/@intFromFloat cannot fit - positive out of range.zig +++ b/test/cases/safety/@intFromFloat cannot fit - positive out of range.zig @@ -2,7 +2,7 @@ const std = @import("std"); pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn { _ = stack_trace; - if (std.mem.eql(u8, message, "integer part of floating point value out of bounds")) { + if (std.mem.eql(u8, message, "integer part of floating point value out of bounds or not finite")) { std.process.exit(0); } std.process.exit(1); diff --git a/test/compile_errors.zig b/test/compile_errors.zig index c61206d7c06b..055d4262dfe0 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -62,7 +62,6 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void { }); } - { const case = ctx.obj("unmatched parentheses", b.graph.host); @@ -74,7 +73,6 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void { ":3:1: error: unmatched curly brace", ":2:2: error: expected 'EOF', found '}'", }); - } {