From 654e0b6679f3436bacbf685223d6ab68f707a62f Mon Sep 17 00:00:00 2001 From: r00ster91 Date: Mon, 3 Oct 2022 19:52:39 +0200 Subject: [PATCH] fix(text): hyphenation and other fixes --- doc/langref.html.in | 4 ++-- lib/std/math.zig | 7 ++++--- lib/std/testing.zig | 8 ++++---- src/Sema.zig | 12 ++++++------ src/type.zig | 2 +- test/behavior/array.zig | 2 +- test/cases/compile_errors/error_in_typeof_param.zig | 2 +- .../explain_why_fn_is_called_at_comptime.zig | 2 +- .../explain_why_generic_fn_is_called_at_comptime.zig | 2 +- .../non-const_switch_number_literal.zig | 2 +- .../non_comptime_param_in_comptime_function.zig | 4 ++-- test/compile_errors.zig | 2 +- 12 files changed, 25 insertions(+), 24 deletions(-) diff --git a/doc/langref.html.in b/doc/langref.html.in index ef9e8402c1..ed6ed63690 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -8043,7 +8043,7 @@ fn func(y: *i32) void { {#header_open|@mulAdd#}
{#syntax#}@mulAdd(comptime T: type, a: T, b: T, c: T) T{#endsyntax#}

- Fused multiply add, similar to {#syntax#}(a * b) + c{#endsyntax#}, except + Fused multiply-add, similar to {#syntax#}(a * b) + c{#endsyntax#}, except only rounds once, and is thus more accurate.

@@ -9178,7 +9178,7 @@ pub const FloatMode = enum {

  • Assume the arguments and result are not +/-Inf. Optimizations are required to retain defined behavior over +/-Inf, but the value of the result is undefined.
  • Treat the sign of a zero argument or result as insignificant.
  • Use the reciprocal of an argument rather than perform division.
  • -
  • Perform floating-point contraction (e.g. fusing a multiply followed by an addition into a fused multiply-and-add).
  • +
  • Perform floating-point contraction (e.g. fusing a multiply followed by an addition into a fused multiply-add).
  • Perform algebraically equivalent transformations that may change results in floating point (e.g. reassociate).
  • This is equivalent to -ffast-math in GCC. diff --git a/lib/std/math.zig b/lib/std/math.zig index a69a6f428c..a4a5da83d1 100644 --- a/lib/std/math.zig +++ b/lib/std/math.zig @@ -762,14 +762,14 @@ fn testOverflow() !void { try testing.expect((shlExact(i32, 0b11, 4) catch unreachable) == 0b110000); } -/// Returns the absolute value of x, where x is a value of an integer -/// type. +/// Returns the absolute value of x, where x is a value of a signed integer type. +/// See also: `absCast` pub fn absInt(x: anytype) !@TypeOf(x) { const T = @TypeOf(x); comptime assert(@typeInfo(T) == .Int); // must pass an integer to absInt comptime assert(@typeInfo(T).Int.signedness == .signed); // must pass a signed integer to absInt - if (x == minInt(@TypeOf(x))) { + if (x == minInt(T)) { return error.Overflow; } else { @setRuntimeSafety(false); @@ -977,6 +977,7 @@ pub inline fn fabs(value: anytype) @TypeOf(value) { /// Returns the absolute value of the integer parameter. /// Result is an unsigned integer. +/// See also: `absInt` pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) { .ComptimeInt => comptime_int, .Int => |int_info| std.meta.Int(.unsigned, int_info.bits), diff --git a/lib/std/testing.zig b/lib/std/testing.zig index 2279e6ef09..60a778ad7a 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -213,8 +213,8 @@ pub fn expectFmt(expected: []const u8, comptime template: []const u8, args: anyt /// This function is intended to be used only in tests. When the actual value is /// not approximately equal to the expected value, prints diagnostics to stderr /// to show exactly how they are not equal, then returns a test failure error. -/// See `math.approxEqAbs` for more informations on the tolerance parameter. -/// The types must be floating point. +/// See `math.approxEqAbs` for more information on the tolerance parameter. +/// The types must be floating-point. pub fn expectApproxEqAbs(expected: anytype, actual: @TypeOf(expected), tolerance: @TypeOf(expected)) !void { const T = @TypeOf(expected); @@ -245,8 +245,8 @@ test "expectApproxEqAbs" { /// This function is intended to be used only in tests. When the actual value is /// not approximately equal to the expected value, prints diagnostics to stderr /// to show exactly how they are not equal, then returns a test failure error. -/// See `math.approxEqRel` for more informations on the tolerance parameter. -/// The types must be floating point. +/// See `math.approxEqRel` for more information on the tolerance parameter. +/// The types must be floating-point. pub fn expectApproxEqRel(expected: anytype, actual: @TypeOf(expected), tolerance: @TypeOf(expected)) !void { const T = @TypeOf(expected); diff --git a/src/Sema.zig b/src/Sema.zig index aed09d6201..9821cf08de 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -5039,7 +5039,7 @@ fn analyzeBlockBody( const valid_rt = try sema.validateRunTimeType(child_block, type_src, resolved_ty, false); if (!valid_rt) { const msg = msg: { - const msg = try sema.errMsg(child_block, type_src, "value with comptime only type '{}' depends on runtime control flow", .{resolved_ty.fmt(mod)}); + const msg = try sema.errMsg(child_block, type_src, "value with comptime-only type '{}' depends on runtime control flow", .{resolved_ty.fmt(mod)}); errdefer msg.destroy(sema.gpa); const runtime_src = child_block.runtime_cond orelse child_block.runtime_loop.?; @@ -5801,12 +5801,12 @@ fn addComptimeReturnTypeNote( break :blk func_src.toSrcLoc(src_decl); }; if (return_ty.tag() == .generic_poison) { - return sema.mod.errNoteNonLazy(src_loc, parent, "generic function is instantiated with a comptime only return type", .{}); + return sema.mod.errNoteNonLazy(src_loc, parent, "generic function is instantiated with a comptime-only return type", .{}); } try sema.mod.errNoteNonLazy( src_loc, parent, - "function is being called at comptime because it returns a comptime only type '{}'", + "function is being called at comptime because it returns a comptime-only type '{}'", .{return_ty.fmt(sema.mod)}, ); try sema.explainWhyTypeIsComptime(block, func_src, parent, src_loc, return_ty); @@ -6343,7 +6343,7 @@ fn analyzeInlineCallArg( new_fn_info.param_types[arg_i.*] = param_ty; const uncasted_arg = uncasted_args[arg_i.*]; if (try sema.typeRequiresComptime(param_ty)) { - _ = sema.resolveConstMaybeUndefVal(arg_block, arg_src, uncasted_arg, "argument to parameter with comptime only type must be comptime known") catch |err| { + _ = sema.resolveConstMaybeUndefVal(arg_block, arg_src, uncasted_arg, "argument to parameter with comptime-only type must be comptime known") catch |err| { if (err == error.AnalysisFail and sema.err != null) { try sema.addComptimeReturnTypeNote(arg_block, func, func_src, ret_ty, sema.err.?, comptime_only_ret_ty); } @@ -8026,7 +8026,7 @@ fn funcCommon( return sema.failWithOwnedErrorMsg(msg); } - // If the return type is comptime only but not dependent on parameters then all parameter types also need to be comptime + // If the return type is comptime-only but not dependent on parameters then all parameter types also need to be comptime if (!sema.is_generic_instantiation and has_body and ret_ty_requires_comptime) comptime_check: { for (block.params.items) |param| { if (!param.is_comptime) break; @@ -8035,7 +8035,7 @@ fn funcCommon( const msg = try sema.errMsg( block, ret_ty_src, - "function with comptime only return type '{}' requires all parameters to be comptime", + "function with comptime-only return type '{}' requires all parameters to be comptime", .{return_type.fmt(sema.mod)}, ); try sema.explainWhyTypeIsComptime(block, ret_ty_src, msg, ret_ty_src.toSrcLoc(sema.owner_decl), return_type); diff --git a/src/type.zig b/src/type.zig index 1fef525062..b6f85b7390 100644 --- a/src/type.zig +++ b/src/type.zig @@ -2318,7 +2318,7 @@ pub const Type = extern union { /// * the type has only one possible value, making its ABI size 0. /// - an enum with an explicit tag type has the ABI size of the integer tag type, /// making it one-possible-value only if the integer tag type has 0 bits. - /// When `ignore_comptime_only` is true, then types that are comptime only + /// When `ignore_comptime_only` is true, then types that are comptime-only /// may return false positives. pub fn hasRuntimeBitsAdvanced( ty: Type, diff --git a/test/behavior/array.zig b/test/behavior/array.zig index 54f87927f5..ab084ff30a 100644 --- a/test/behavior/array.zig +++ b/test/behavior/array.zig @@ -564,7 +564,7 @@ test "type coercion of pointer to anon struct literal to pointer to array" { comptime try S.doTheTest(); } -test "array with comptime only element type" { +test "array with comptime-only element type" { const a = [_]type{ u32, i32 }; try testing.expect(a[0] == u32); try testing.expect(a[1] == i32); diff --git a/test/cases/compile_errors/error_in_typeof_param.zig b/test/cases/compile_errors/error_in_typeof_param.zig index 747cdf3df6..e064713ada 100644 --- a/test/cases/compile_errors/error_in_typeof_param.zig +++ b/test/cases/compile_errors/error_in_typeof_param.zig @@ -11,4 +11,4 @@ pub export fn entry() void { // target=native // // :6:31: error: unable to resolve comptime value -// :6:31: note: argument to parameter with comptime only type must be comptime known +// :6:31: note: argument to parameter with comptime-only type must be comptime known diff --git a/test/cases/compile_errors/explain_why_fn_is_called_at_comptime.zig b/test/cases/compile_errors/explain_why_fn_is_called_at_comptime.zig index 04f64c2303..84e3f65c5c 100644 --- a/test/cases/compile_errors/explain_why_fn_is_called_at_comptime.zig +++ b/test/cases/compile_errors/explain_why_fn_is_called_at_comptime.zig @@ -18,6 +18,6 @@ pub export fn entry() void { // // :12:13: error: unable to resolve comptime value // :12:13: note: argument to function being called at comptime must be comptime known -// :7:25: note: function is being called at comptime because it returns a comptime only type 'tmp.S' +// :7:25: note: function is being called at comptime because it returns a comptime-only type 'tmp.S' // :2:12: note: struct requires comptime because of this field // :2:12: note: use '*const fn() void' for a function pointer type diff --git a/test/cases/compile_errors/explain_why_generic_fn_is_called_at_comptime.zig b/test/cases/compile_errors/explain_why_generic_fn_is_called_at_comptime.zig index ccd828bd5c..3eeb010f4e 100644 --- a/test/cases/compile_errors/explain_why_generic_fn_is_called_at_comptime.zig +++ b/test/cases/compile_errors/explain_why_generic_fn_is_called_at_comptime.zig @@ -19,4 +19,4 @@ pub export fn entry() void { // // :14:13: error: unable to resolve comptime value // :14:13: note: argument to function being called at comptime must be comptime known -// :9:38: note: generic function is instantiated with a comptime only return type +// :9:38: note: generic function is instantiated with a comptime-only return type diff --git a/test/cases/compile_errors/non-const_switch_number_literal.zig b/test/cases/compile_errors/non-const_switch_number_literal.zig index 01e31bb92c..699edb5232 100644 --- a/test/cases/compile_errors/non-const_switch_number_literal.zig +++ b/test/cases/compile_errors/non-const_switch_number_literal.zig @@ -14,5 +14,5 @@ fn bar() i32 { // backend=stage2 // target=native // -// :2:15: error: value with comptime only type 'comptime_int' depends on runtime control flow +// :2:15: error: value with comptime-only type 'comptime_int' depends on runtime control flow // :2:26: note: runtime control flow here diff --git a/test/cases/compile_errors/non_comptime_param_in_comptime_function.zig b/test/cases/compile_errors/non_comptime_param_in_comptime_function.zig index 758166dd7f..5e8457cd43 100644 --- a/test/cases/compile_errors/non_comptime_param_in_comptime_function.zig +++ b/test/cases/compile_errors/non_comptime_param_in_comptime_function.zig @@ -26,10 +26,10 @@ export fn entry2() void { // backend=stage2 // target=native // -// :1:20: error: function with comptime only return type 'type' requires all parameters to be comptime +// :1:20: error: function with comptime-only return type 'type' requires all parameters to be comptime // :1:20: note: types are not available at runtime // :1:6: note: param 'val' is required to be comptime -// :11:16: error: function with comptime only return type 'tmp.S' requires all parameters to be comptime +// :11:16: error: function with comptime-only return type 'tmp.S' requires all parameters to be comptime // :9:10: note: struct requires comptime because of this field // :9:10: note: use '*const fn() void' for a function pointer type // :11:8: note: param is required to be comptime diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 96df66d081..ba268b88c1 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -204,7 +204,7 @@ pub fn addCases(ctx: *TestContext) !void { , &[_][]const u8{ ":3:12: error: unable to resolve comptime value", ":3:12: note: argument to function being called at comptime must be comptime known", - ":2:55: note: generic function is instantiated with a comptime only return type", + ":2:55: note: generic function is instantiated with a comptime-only return type", }); }