mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +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:
parent
887e13f364
commit
0b86574293
1 changed files with 9 additions and 2 deletions
|
@ -1533,7 +1533,8 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@function.name:snakecase@)
|
||||||
auto argument_count = overloaded_function.parameters.size();
|
auto argument_count = overloaded_function.parameters.size();
|
||||||
|
|
||||||
function_generator.set("argument_count", String::number(argument_count));
|
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));
|
function_generator.set("overload_suffix", String::number(i));
|
||||||
|
|
||||||
if (argument_count > fetched_arguments) {
|
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@)
|
if (@arguments_match_check@)
|
||||||
return @function.name:snakecase@@overload_suffix@(vm, global_object);
|
return @function.name:snakecase@@overload_suffix@(vm, global_object);
|
||||||
)~~~");
|
)~~~");
|
||||||
|
}
|
||||||
|
|
||||||
if (!is_last) {
|
if (!is_last) {
|
||||||
function_generator.append(R"~~~(
|
function_generator.append(R"~~~(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue