fix(text): hyphenation and other fixes

This commit is contained in:
r00ster91 2022-10-03 19:52:39 +02:00
parent 34835bbbcf
commit 654e0b6679
12 changed files with 25 additions and 24 deletions

View file

@ -8043,7 +8043,7 @@ fn func(y: *i32) void {
{#header_open|@mulAdd#}
<pre>{#syntax#}@mulAdd(comptime T: type, a: T, b: T, c: T) T{#endsyntax#}</pre>
<p>
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.
</p>
<p>
@ -9178,7 +9178,7 @@ pub const FloatMode = enum {
<li>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.</li>
<li>Treat the sign of a zero argument or result as insignificant.</li>
<li>Use the reciprocal of an argument rather than perform division.</li>
<li>Perform floating-point contraction (e.g. fusing a multiply followed by an addition into a fused multiply-and-add).</li>
<li>Perform floating-point contraction (e.g. fusing a multiply followed by an addition into a fused multiply-add).</li>
<li>Perform algebraically equivalent transformations that may change results in floating point (e.g. reassociate).</li>
</ul>
This is equivalent to <code>-ffast-math</code> in GCC.

View file

@ -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),

View file

@ -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);

View file

@ -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);

View file

@ -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,

View file

@ -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);

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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",
});
}