Support for typeof. (#7858)

Implements `typeof(expr)`, as described in #7697. `expr` is treated as
an unevaluated operand, and is kept in an `ExprRegion` separate from the
enclosing scope.

Assisted-by: Claude via Antigravity
This commit is contained in:
Richard Smith
2026-09-29 21:13:51 +00:00
committed by GitHub
parent 99f910f179
commit 4ca08b136d
18 changed files with 846 additions and 5 deletions
+6 -4
View File
@@ -355,10 +355,12 @@ class Stringifier {
template <typename InstT>
auto StringifyInst(InstId inst_id, InstT inst) -> void {
// This doesn't use requires so that more specific overloads are chosen when
// provided.
static_assert(InstT::Kind.is_type() != InstIsType::Always ||
std::same_as<InstT, WhereExpr>,
"Types should have a dedicated overload");
// provided. Indirect constants can be printed by desugaring.
static_assert(
InstT::Kind.is_type() != InstIsType::Always ||
InstT::Kind.constant_kind() == InstConstantKind::Indirect ||
std::same_as<InstT, WhereExpr>,
"Types should have a dedicated overload");
// TODO: We should have Stringify support for all types where
// InstT::Kind.constant_kind() is neither Never nor Indirect.
StringifyInstDefault(inst_id, inst);