Support floats in MapAPValueToConstant (#6800)

This allows `constexpr float` to be properly imported as a constant.
This commit is contained in:
Nicholas Bishop
2026-02-26 19:48:19 +00:00
committed by GitHub
parent d11ee4b2b1
commit 96f163f114
2 changed files with 16 additions and 0 deletions
+4
View File
@@ -30,6 +30,10 @@ auto MapAPValueToConstant(Context& context, SemIR::LocId loc_id,
return TryEvalInst(context,
SemIR::IntValue{.type_id = type_id, .int_id = int_id});
}
} else if (ap_value.isFloat()) {
FloatId float_id = context.floats().Add(ap_value.getFloat());
return TryEvalInst(
context, SemIR::FloatValue{.type_id = type_id, .float_id = float_id});
} else {
// TODO: support other types.
return SemIR::ConstantId::NotConstant;