Zig: Remove fields on `type` redundant with @typeInfo

Created on 31 Aug 2020  路  5Comments  路  Source: ziglang/zig

I think these are already deprecated from scattered comments on issues, but it would be nice to have an accepted issue to point to.

  • Int

    • bit_count

    • is_signed

  • Float

    • bit_count

  • Pointer

    • Child

    • alignment

  • Array

    • Child

    • len

  • ErrorUnion

    • Payload

    • ErrorSet

  • Optional

    • Child

  • Fn

    • ReturnType

    • is_var_args

    • arg_count

accepted proposal

Most helpful comment

No. zig fmt doesn't know anything about types and would just lead to more breakage. However I believe these are quite rare in anything made after the introduction of @typeInfo.

All 5 comments

Notably, if we remove these (which I think we should), they should be removed from error messages too.
Infact, the change in error messages can occur first.

I think the only time it shows up in error messages is for the name of an inferred error set:

buf_appendf(&err_set_type->name, "@TypeOf(%s).ReturnType.ErrorSet", buf_ptr(&fn_entry->symbol_name));

Not sure what to replace it with.

Duplicate of #2117 assuming it applies to all the other redundant fields.

@Vexu would it be possible to have zig fmt replace usages of these deprecated fields with their standard library equivalents?

No. zig fmt doesn't know anything about types and would just lead to more breakage. However I believe these are quite rare in anything made after the introduction of @typeInfo.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bheads picture bheads  路  3Comments

andrewrk picture andrewrk  路  3Comments

andrewrk picture andrewrk  路  3Comments

dobkeratops picture dobkeratops  路  3Comments

komuw picture komuw  路  3Comments