mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 11:36:10 +00:00
LibWeb/Bindings: Allow optional string returned in a union
This is not a very pleasant fix, but matches a similar const_cast that we do to return JS objects returned in a union. Ideally we would 'simply' remove the const from the value being visited in the variant, but that opens up a whole can of worms where we are currently relying on temporary lifetime extension so that interfaces can return a Variant of GC::Ref's to JS::Objects.
This commit is contained in:
parent
f3ec727555
commit
ba382c454a
Notes:
github-actions[bot]
2025-02-10 17:06:19 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/ba382c454a5 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3237 Reviewed-by: https://github.com/tcl3 ✅
1 changed files with 4 additions and 1 deletions
|
@ -1821,8 +1821,11 @@ static void generate_wrap_statement(SourceGenerator& generator, ByteString const
|
|||
|
||||
if (type.is_string()) {
|
||||
if (type.is_nullable() || is_optional) {
|
||||
// FIXME: Ideally we would not need to do this const_cast, but we currently rely on temporary
|
||||
// lifetime extension to allow Variants to compile and handle an interface returning a
|
||||
// GC::Ref while the generated code will visit it as a GC::Root.
|
||||
scoped_generator.append(R"~~~(
|
||||
@result_expression@ JS::PrimitiveString::create(vm, @value@.release_value());
|
||||
@result_expression@ JS::PrimitiveString::create(vm, const_cast<decltype(@value@)&>(@value@).release_value());
|
||||
)~~~");
|
||||
} else {
|
||||
scoped_generator.append(R"~~~(
|
||||
|
|
Loading…
Add table
Reference in a new issue