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

Error using partial_double probably caused by: "p_script->implicit_initializer" is null #570

Open
bitwes opened this issue Feb 21, 2024 · 1 comment
Labels

Comments

@bitwes
Copy link
Owner

bitwes commented Feb 21, 2024

Godot version:  4.2.0
GUT version:  9.2.0

This does not happen when running the script by itself or just the test. It only happens when multiple scripts are run. I'm not sure what is causing the error, or easier steps to replicate but I wanted to get it in here in case anyone else runs into it.

Something is happening when the partial double is being created, resulting in an invalid object. The source for the partial double is below.

KlondikeOptions is a simple class that only has a class_name and does not extend anything. It's basically a struct with some save/load methods.

The line generating the error is in here: https://github.com/godotengine/godot/blob/master/modules/gdscript/gdscript.cpp

Test generating error

func test_save_file_calls_save_to_config_file():
	gut.get_doubler().print_source = true
	var to_save = partial_double(KlondikeOptions).new()
	to_save.save_file(SAVE_PATH)
	assert_called(to_save, 'save_to_config_file')
	gut.get_doubler().print_source = false

Output

res://test/unit/test_klondike_options.gd
* test_can_make_one
* test_load_sets_values
* test_save_file_creates_file
* test_save_file_calls_save_to_config_file
     1 |# ##############################################################################
     2 |# Gut Doubled Script
     3 |# ##############################################################################
     4 |extends 'res://scripts/klondike_options.gd'
     5 |
     6 |
     7 |
     8 |
     9 |
    10 |# ------------------------------------------------------------------------------
    11 |# GUT stuff
    12 |# ------------------------------------------------------------------------------
    13 |var __gutdbl_values = {
    14 |	double = self,
    15 |	thepath = 'res://scripts/klondike_options.gd',
    16 |	subpath = '',
    17 |	stubber = -9223371941258196898,
    18 |	spy = -9223371940754880409,
    19 |	gut = 95110039638,
    20 |	from_singleton = '',
    21 |	is_partial = true,
    22 |	doubled_methods = ["save_to_config_file", "save_file", "load_from_config_file", "load_file"],
    23 |}
    24 |var __gutdbl = load('res://addons/gut/double_tools.gd').new(__gutdbl_values)
    25 |
    26 |# Here so other things can check for a method to know if this is a double.
    27 |func __gutdbl_check_method__():
    28 |	pass
    29 |
    30 |# ------------------------------------------------------------------------------
    31 |# Doubled Methods
    32 |# ------------------------------------------------------------------------------
    33 |
    34 |
    35 |func save_to_config_file(p_config_file=__gutdbl.default_val("save_to_config_file",0)):
    36 |	__gutdbl.spy_on('save_to_config_file', [p_config_file])
    37 |	if(__gutdbl.should_call_super('save_to_config_file', [p_config_file])):
    38 |		return await super(p_config_file)
    39 |	else:
    40 |		return __gutdbl.get_stubbed_return('save_to_config_file', [p_config_file])
    41 |
    42 |
    43 |func save_file(p_path=__gutdbl.default_val("save_file",0)):
    44 |	__gutdbl.spy_on('save_file', [p_path])
    45 |	if(__gutdbl.should_call_super('save_file', [p_path])):
    46 |		return await super(p_path)
    47 |	else:
    48 |		return __gutdbl.get_stubbed_return('save_file', [p_path])
    49 |
    50 |
    51 |func load_from_config_file(p_config_file=__gutdbl.default_val("load_from_config_file",0)):
    52 |	__gutdbl.spy_on('load_from_config_file', [p_config_file])
    53 |	if(__gutdbl.should_call_super('load_from_config_file', [p_config_file])):
    54 |		return await super(p_config_file)
    55 |	else:
    56 |		return __gutdbl.get_stubbed_return('load_from_config_file', [p_config_file])
    57 |
    58 |
    59 |func load_file(p_path=__gutdbl.default_val("load_file",0)):
    60 |	__gutdbl.spy_on('load_file', [p_path])
    61 |	if(__gutdbl.should_call_super('load_file', [p_path])):
    62 |		return await super(p_path)
    63 |	else:
    64 |		return __gutdbl.get_stubbed_return('load_file', [p_path])
    65 |
    66 |
    67 |

ERROR: Parameter "p_script->implicit_initializer" is null.
   at: _super_implicit_constructor (modules/gdscript/gdscript.cpp:136)

Debugger Break, Reason: 'Invalid call. Nonexistent function 'save_file'.'
*Frame 0 - :46 in function 'save_file'
Enter "help" for assistance.
debug> bt
*Frame 0 - :46 in function 'save_file'
 Frame 1 - res://test/unit/test_klondike_options.gd:46 in function 'test_save_file_calls_save_to_config_file'
 Frame 2 - res://addons/gut/gut.gd:580 in function '_run_test'
 Frame 3 - res://addons/gut/gut.gd:757 in function '_test_the_scripts'
debug>
@bitwes
Copy link
Owner Author

bitwes commented Feb 23, 2024

I think this is the same issue as #490

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant