IDLGenerators: Correctly treat optional enums as optional

Specifically, this makes enums in dictionaries not cause compile errors.
This commit is contained in:
Sam Atkins 2025-08-22 11:50:36 +01:00 committed by Andreas Kling
parent e174215845
commit ffb236adbd

View File

@ -2067,7 +2067,7 @@ static void generate_wrap_statement(SourceGenerator& generator, ByteString const
)~~~");
} else if (interface.enumerations.contains(type.name())) {
// Handle Enum? values, which were null-checked above
if (type.is_nullable())
if (type.is_nullable() || is_optional)
scoped_generator.set("value", ByteString::formatted("{}.value()", value));
scoped_generator.append(R"~~~(
@result_expression@ JS::PrimitiveString::create(vm, Bindings::idl_enum_to_string(@value@));