1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 00:37:35 +00:00

LibWeb: Verify argument_check before generating if statement

This fixes an error where we would generate an empty 'if' statement body
if argument_check was empty.
This commit is contained in:
Kenneth Myhra 2022-04-03 18:37:44 +02:00 committed by Andreas Kling
parent 887e13f364
commit 0b86574293

View file

@ -1533,7 +1533,8 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@function.name:snakecase@)
auto argument_count = overloaded_function.parameters.size();
function_generator.set("argument_count", String::number(argument_count));
function_generator.set("arguments_match_check", generate_arguments_match_check(overloaded_function));
auto arguments_match_check = generate_arguments_match_check(overloaded_function);
function_generator.set("arguments_match_check", arguments_match_check);
function_generator.set("overload_suffix", String::number(i));
if (argument_count > fetched_arguments) {
@ -1553,10 +1554,16 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@function.name:snakecase@)
)~~~");
}
function_generator.append(R"~~~(
if (arguments_match_check.is_empty()) {
function_generator.append(R"~~~(
return @function.name:snakecase@@overload_suffix@(vm, global_object);
)~~~");
} else {
function_generator.append(R"~~~(
if (@arguments_match_check@)
return @function.name:snakecase@@overload_suffix@(vm, global_object);
)~~~");
}
if (!is_last) {
function_generator.append(R"~~~(