Skip to content

Commit 106df88

Browse files
committed
Sema: add doc comments for comptime reason types
1 parent 9ff80d7 commit 106df88

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Sema.zig

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,11 +845,15 @@ pub const Block = struct {
845845
}
846846
};
847847

848+
/// Represents the reason we are resolving a value or evaluating code at comptime.
849+
/// Most reasons are represented by a `std.zig.SimpleComptimeReason`, which provides a plain message.
848850
const ComptimeReason = union(enum) {
849851
/// Evaluating at comptime for a reason in the `std.zig.SimpleComptimeReason` enum.
850852
simple: std.zig.SimpleComptimeReason,
851853

852-
/// Evaluating at comptime because of a comptime-only type.
854+
/// Evaluating at comptime because of a comptime-only type. This field is separate so that
855+
/// the type in question can be included in the error message. AstGen could never emit this
856+
/// reason, because it knows nothing of types.
853857
/// The format string looks like "foo '{}' bar", where "{}" is the comptime-only type.
854858
/// We will then explain why this type is comptime-only.
855859
comptime_only: struct {
@@ -885,12 +889,14 @@ const ComptimeReason = union(enum) {
885889
}
886890
};
887891

892+
/// Represents the reason a `Block` is being evaluated at comptime.
888893
const BlockComptimeReason = union(enum) {
889894
/// This block inherits being comptime-only from the `inlining` call site.
890895
inlining_parent,
891896

892-
/// This block is comptime for the given reason at the given source location.
897+
/// Comptime evaluation began somewhere in the current function for a given `ComptimeReason`.
893898
reason: struct {
899+
/// The source location which this reason originates from. `r` is reported here.
894900
src: LazySrcLoc,
895901
r: ComptimeReason,
896902
},

0 commit comments

Comments
 (0)