Decl
has two main responsibilities today.
The first is to act as the "subject" of semantic analysis for anything analyzed in a comptime
context. For instance, when analyzing the value of a container-level const
, that declaration's Decl
is the "owner" of that Sema
; errors are marked on it, source locations resolved relative to it, etc. This is also where type owner decls come from - we need some context in which to perform type resolution, so we need a Decl
associated with the type itself.
The second is to represent a globally named and/or addressable value. For instance, container-level const
s are named and addressable. More interestingly, so are generic instantiations - you can't take their address in Zig today, but they sure as hell have one, and same with name. This is where function instance owner decls come from.
Interestingly, above, we found that owner decls for types and owner decls for function instances are fulfiling two totally separate purposes! To me, tha