comptime enum value params: $o: EnumType binds+resolves variant tag
A comptime value param whose constraint is a plain enum ($o: Ord) now binds its enum-literal argument to the variant tag during inlined comptime-call lowering. The tag is recorded in comptime_value_bindings (readable downstream via comptimeIntNamed / direct map lookup, and as an array-dim style const-int leaf) AND the param is bound into scope as an enum_init value so body comparisons like 'if o == .a' lower as ordinary enum comparisons. Distinct ordering args monomorphize the inlined body per value. A non-constant argument or an unknown variant emits a loud diagnostic and binds nothing — never a silent default. Locked by examples/0627-comptime-enum-value-param.sx.
This commit is contained in:
@@ -1572,6 +1572,7 @@ pub const Lowering = struct {
|
||||
pub const lowerComptimeGlobal = lower_comptime.lowerComptimeGlobal;
|
||||
pub const lowerComptimeSideEffect = lower_comptime.lowerComptimeSideEffect;
|
||||
pub const lowerComptimeCall = lower_comptime.lowerComptimeCall;
|
||||
pub const bindEnumValueParams = lower_comptime.bindEnumValueParams;
|
||||
pub const lowerInlineComptime = lower_comptime.lowerInlineComptime;
|
||||
pub const lowerInsertExpr = lower_comptime.lowerInsertExpr;
|
||||
pub const lowerInsertExprValue = lower_comptime.lowerInsertExprValue;
|
||||
|
||||
Reference in New Issue
Block a user