Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement RETURN_VALUE_DISCARDED warning in GDscript #67361

Merged

Conversation

clayjohn
Copy link
Member

Fixes: #66100

RETURN_VALUE_DISCARDED wasn't implemented yet in master so no errors were printed when users called functions and ignored the return value

@clayjohn clayjohn added this to the 4.0 milestone Oct 13, 2022
@clayjohn clayjohn requested a review from a team as a code owner October 13, 2022 17:41
@akien-mga
Copy link
Member

It seems to fail the GDScript test suite:

>> The function 'call()' returns a value, but this value is never used.
foo
foo
bar
true


modules/gdscript/tests/gdscript_test_runner.cpp:198: ERROR: CHECK( result.passed ) is NOT correct!
  values: CHECK( false )
  logged: /home/runner/work/godot/godot/modules/gdscript/tests/scripts/runtime/features/params_default_values.gd
          GDTEST_OK
>> WARNING
>> Line: 4
>> RETURN_VALUE_DISCARDED
>> The function 'const_default()' returns a value, but this value is never used.
>> WARNING
>> Line: 5
>> RETURN_VALUE_DISCARDED
>> The function 'func_result_default()' returns a value, but this value is never used.
>> WARNING
>> Line: 9
>> RETURN_VALUE_DISCARDED
>> The function 'func_result_default()' returns a value, but this value is never used.
>> WARNING
>> Line: 10
>> RETURN_VALUE_DISCARDED
>> The function 'lots_of_defaults()' returns a value, but this value is never used.
>> WARNING
>> Line: 12
>> RETURN_VALUE_DISCARDED
>> The function 'ref_default()' returns a value, but this value is never used.
42
1
2
non-optional 1 2 3
non-optional 42 non-optional 41


./modules/gdscript/tests/gdscript_test_runner_suite.h:47: FATAL ERROR: REQUIRE( fail_count == 0 ) is NOT correct!
  values: REQUIRE( 22 == 0 )
  logged: Make sure `*.out` files have expected results.
          All GDScript tests should pass.

@clayjohn
Copy link
Member Author

clayjohn commented Oct 13, 2022

It seems to fail the GDScript test suite:

>> The function 'call()' returns a value, but this value is never used.
foo
foo
bar
true


modules/gdscript/tests/gdscript_test_runner.cpp:198: ERROR: CHECK( result.passed ) is NOT correct!
  values: CHECK( false )
  logged: /home/runner/work/godot/godot/modules/gdscript/tests/scripts/runtime/features/params_default_values.gd
          GDTEST_OK
>> WARNING
>> Line: 4
>> RETURN_VALUE_DISCARDED
>> The function 'const_default()' returns a value, but this value is never used.
>> WARNING
>> Line: 5
>> RETURN_VALUE_DISCARDED
>> The function 'func_result_default()' returns a value, but this value is never used.
>> WARNING
>> Line: 9
>> RETURN_VALUE_DISCARDED
>> The function 'func_result_default()' returns a value, but this value is never used.
>> WARNING
>> Line: 10
>> RETURN_VALUE_DISCARDED
>> The function 'lots_of_defaults()' returns a value, but this value is never used.
>> WARNING
>> Line: 12
>> RETURN_VALUE_DISCARDED
>> The function 'ref_default()' returns a value, but this value is never used.
42
1
2
non-optional 1 2 3
non-optional 42 non-optional 41


./modules/gdscript/tests/gdscript_test_runner_suite.h:47: FATAL ERROR: REQUIRE( fail_count == 0 ) is NOT correct!
  values: REQUIRE( 22 == 0 )
  logged: Make sure `*.out` files have expected results.
          All GDScript tests should pass.

Looks like it is working! I'll clean up the tests I spoke too soon, these tests shouldn't fail

@clayjohn clayjohn force-pushed the GDScript-unused-return-warning branch from 415d58f to b277fca Compare October 13, 2022 18:56
@clayjohn
Copy link
Member Author

@akien-mga This should be ready for review now

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@akien-mga akien-mga merged commit 343bb9c into godotengine:master Oct 14, 2022
@akien-mga
Copy link
Member

Thanks!

@clayjohn clayjohn deleted the GDScript-unused-return-warning branch October 14, 2022 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GDScript 2.0: return_value_discarded warning not happening
2 participants