@@ -8351,6 +8351,7 @@ pub const TypeInfo = union(TypeId) {
8351
8351
alignment: comptime_int,
8352
8352
child: type,
8353
8353
is_allowzero: bool,
8354
+ sentinel: var,
8354
8355
8355
8356
pub const Size = enum {
8356
8357
One,
@@ -8363,6 +8364,7 @@ pub const TypeInfo = union(TypeId) {
8363
8364
pub const Array = struct {
8364
8365
len: comptime_int,
8365
8366
child: type,
8367
+ sentinel: var,
8366
8368
};
8367
8369
8368
8370
pub const ContainerLayout = enum {
@@ -8493,6 +8495,24 @@ pub const TypeInfo = union(TypeId) {
8493
8495
{#link|error sets|Error Set Type#}, the fields are guaranteed to be in the same
8494
8496
order as declared. For declarations, the order is unspecified.
8495
8497
</p>
8498
+ <p>
8499
+ Note that the {#syntax#}sentinel{#endsyntax} field in {#syntax#}TypeInfo.Pointer{#endsyntax#}
8500
+ and {#syntax#}TypeInfo.Array{#endsyntax#} is of type {#syntax#}var{#endsyntax#} rather
8501
+ than {#syntax#}?child{#endsyntax#}. {#syntax#}TypeInfo.Pointer{#endsyntax#}
8502
+ and {#syntax#}TypeInfo.Array{#endsyntax#} can be constructed with any comptime value for the
8503
+ {#syntax#}sentinel{#endsyntax} field. However, the {#syntax#}@Type{#endsyntax#} builtin will
8504
+ only accept the TypeInfo struct if the sentinel value is implicitly convertible to
8505
+ {#syntax#}child{#endsyntax#}. Furthermore, any {#syntax#}TypeInfo.Pointer{#endsyntax#}
8506
+ or {#syntax#}TypeInfo.Array{#endsyntax#} retreived from {#syntax#}@typeInfo{#endsyntax#} will
8507
+ guarantee that {#syntax#}@typeOf(sentinel){#endsyntax#} is equal to
8508
+ {#syntax#}?child{#endsyntax#}. For example, {#syntax#}@typeOf(sentinel){#endsyntax} for a
8509
+ {#syntax#}TypeInfo.Pointer{#endsyntax#} constructed with
8510
+ {#syntax#}TypeInfo.Pointer { ... .sentinel = 0; ... }{#endsyntax#} would be
8511
+ {#syntax#}comptime_int{#endsyntax#} rather than {#syntax#}?u8{#endsyntax#}. However, if you
8512
+ passed that {#syntax#}TypeInfo.Pointer{#endsyntax#} struct to
8513
+ {#syntax#}@typeInfo(@Type(myPointerInfo)){#endsyntax#} then {#syntax#}@typeOf(sentinel){#endsyntax}
8514
+ would be {#syntax#}?u8{#endsyntax#}.
8515
+ </p>
8496
8516
{#header_close#}
8497
8517
8498
8518
{#header_open|@typeName#}
0 commit comments