@@ -8363,6 +8363,7 @@ pub const TypeInfo = union(TypeId) {
8363
8363
alignment: comptime_int,
8364
8364
child: type,
8365
8365
is_allowzero: bool,
8366
+ sentinel: var,
8366
8367
8367
8368
pub const Size = enum {
8368
8369
One,
@@ -8375,6 +8376,7 @@ pub const TypeInfo = union(TypeId) {
8375
8376
pub const Array = struct {
8376
8377
len: comptime_int,
8377
8378
child: type,
8379
+ sentinel: var,
8378
8380
};
8379
8381
8380
8382
pub const ContainerLayout = enum {
@@ -8505,6 +8507,24 @@ pub const TypeInfo = union(TypeId) {
8505
8507
{#link|error sets|Error Set Type#}, the fields are guaranteed to be in the same
8506
8508
order as declared. For declarations, the order is unspecified.
8507
8509
</p>
8510
+ <p>
8511
+ Note that the {#syntax#}sentinel{#endsyntax#} field in {#syntax#}TypeInfo.Pointer{#endsyntax#}
8512
+ and {#syntax#}TypeInfo.Array{#endsyntax#} is of type {#syntax#}var{#endsyntax#} rather
8513
+ than {#syntax#}?child{#endsyntax#}. {#syntax#}TypeInfo.Pointer{#endsyntax#}
8514
+ and {#syntax#}TypeInfo.Array{#endsyntax#} can be constructed with any comptime value for the
8515
+ {#syntax#}sentinel{#endsyntax#} field. However, the {#syntax#}@Type{#endsyntax#} builtin will
8516
+ only accept the TypeInfo struct if the sentinel value is implicitly convertible to
8517
+ {#syntax#}child{#endsyntax#}. Furthermore, any {#syntax#}TypeInfo.Pointer{#endsyntax#}
8518
+ or {#syntax#}TypeInfo.Array{#endsyntax#} retreived from {#syntax#}@typeInfo{#endsyntax#} will
8519
+ guarantee that {#syntax#}@typeOf(sentinel){#endsyntax#} is equal to
8520
+ {#syntax#}?child{#endsyntax#}. For example, {#syntax#}@typeOf(sentinel){#endsyntax#} for a
8521
+ {#syntax#}TypeInfo.Pointer{#endsyntax#} constructed with
8522
+ {#syntax#}TypeInfo.Pointer { ... .sentinel = 0; ... }{#endsyntax#} would be
8523
+ {#syntax#}comptime_int{#endsyntax#} rather than {#syntax#}?u8{#endsyntax#}. However, if you
8524
+ passed that {#syntax#}TypeInfo.Pointer{#endsyntax#} struct to
8525
+ {#syntax#}@typeInfo(@Type(myPointerInfo)){#endsyntax#} then {#syntax#}@typeOf(sentinel){#endsyntax#}
8526
+ would be {#syntax#}?u8{#endsyntax#}.
8527
+ </p>
8508
8528
{#header_close#}
8509
8529
8510
8530
{#header_open|@typeName#}
0 commit comments