Open Torguen opened 1 year ago
Please add the errors as text, not everyone can watch the video and it's only very briefly visible
Ok!.
The error pretty much says it all, you can't call this function on Batonnes
, it is a class, you need an instance
Without knowing more about your code I can't tell what you're trying to do, but this would be best served in the other community channels, as it isn't a bug
The error is correct and expected, what's a bug is the crash which happens when typing the dot after Batonnes.find_node( "Controles" ).
- as seen in the video the editor crashes, it shouldn't.
Oh my bad missed that from the video
I can reproduce the crash in 3.6-beta2, but not in 4.0+, which also doesn't raise an error for this syntax in the editor (but raises one at runtime).
MRP: Test3x_GDScriptAutocompleteCrash.zip
Backtrace from cebaa3f763ef05a4ee189f5ac13fb023d365eeaf:
SCRIPT ERROR: Parse Error: Non-static function "find_node" can only be called from an instance.
at: GDScript::reload (res://Node2D.gd:12)
Thread 1 "godot-3.x" received signal SIGSEGV, Segmentation fault.
0x00000000035f696a in Node::find_node (this=0x8d2d580, p_mask=..., p_recursive=true, p_owned=true) at scene/main/node.cpp:1500
1500 if (p_owned && !cptr[i]->data.owner) {
(gdb) bt
#0 0x00000000035f696a in Node::find_node (this=0x8d2d580, p_mask=..., p_recursive=true, p_owned=true) at scene/main/node.cpp:1500
#1 0x000000000361d18d in MethodBind3RC<Node*, String const&, bool, bool>::call (this=0x7d7d280, p_object=0x8d2d580, p_args=0x1230a0d0, p_arg_count=1, r_error=...) at ./core/method_bind.gen.inc:2849
#2 0x0000000001984b04 in _guess_expression_type (p_context=..., p_expression=0x127b1180, r_type=...) at modules/gdscript/gdscript_editor.cpp:886
#3 0x0000000001991a51 in GDScriptLanguage::complete_code (this=0x7d81f30, p_code=..., p_path=..., p_owner=0x1046e450, r_options=0x7fffffffb718, r_forced=@0x7fffffffb70f: false, r_call_hint=...)
at modules/gdscript/gdscript_editor.cpp:2669
#4 0x0000000003061706 in ScriptTextEditor::_code_complete_script (this=0x1226bb90, p_code=..., r_options=0x7fffffffb718, r_force=@0x7fffffffb70f: false) at editor/plugins/script_text_editor.cpp:820
#5 0x00000000030615fa in ScriptTextEditor::_code_complete_scripts (p_ud=0x1226bb90, p_code=..., r_options=0x7fffffffb718, r_force=@0x7fffffffb70f: false) at editor/plugins/script_text_editor.cpp:808
#6 0x00000000033e35f8 in CodeTextEditor::_complete_request (this=0x11fff5b0) at editor/code_editor.cpp:834
#7 0x000000000192867c in MethodBind0::call (this=0xea19bf0, p_object=0x11fff5b0, p_args=0x7fffffffba60, p_arg_count=0, r_error=...) at ./core/method_bind.gen.inc:59
#8 0x000000000460bd64 in Object::call (this=0x11fff5b0, p_method=..., p_args=0x7fffffffba60, p_argcount=0, r_error=...) at core/object.cpp:918
#9 0x000000000460dc1d in Object::emit_signal (this=0x12277cd0, p_name=..., p_args=0x7fffffffba60, p_argcount=0) at core/object.cpp:1230
#10 0x000000000460e2df in Object::emit_signal (this=0x12277cd0, p_name=..., p_arg1=..., p_arg2=..., p_arg3=..., p_arg4=..., p_arg5=..., p_arg6=..., p_arg7=..., p_arg8=...) at core/object.cpp:1285
#11 0x000000000385ef71 in TextEdit::query_code_comple (this=0x12277cd0) at scene/gui/text_edit.cpp:7033
#12 0x00000000033e355e in CodeTextEditor::_code_complete_timer_timeout (this=0x11fff5b0) at editor/code_editor.cpp:825
#13 0x000000000192867c in MethodBind0::call (this=0xea19af0, p_object=0x11fff5b0, p_args=0x7fffffffc100, p_arg_count=0, r_error=...) at ./core/method_bind.gen.inc:59
#14 0x000000000460bd64 in Object::call (this=0x11fff5b0, p_method=..., p_args=0x7fffffffc100, p_argcount=0, r_error=...) at core/object.cpp:918
#15 0x000000000460dc1d in Object::emit_signal (this=0x11d725e0, p_name=..., p_args=0x7fffffffc100, p_argcount=0) at core/object.cpp:1230
#16 0x000000000460e2df in Object::emit_signal (this=0x11d725e0, p_name=..., p_arg1=..., p_arg2=..., p_arg3=..., p_arg4=..., p_arg5=..., p_arg6=..., p_arg7=..., p_arg8=...) at core/object.cpp:1285
#17 0x000000000364ad74 in Timer::_notification (this=0x11d725e0, p_what=25) at scene/main/timer.cpp:61
#18 0x000000000364d5c8 in Timer::_notificationv (this=0x11d725e0, p_notification=25, p_reversed=false) at scene/main/timer.h:37
#19 0x000000000460be81 in Object::notification (this=0x11d725e0, p_notification=25, p_reversed=false) at core/object.cpp:927
#20 0x000000000362a79e in SceneTree::_notify_group_pause (this=0x701c9b0, p_group=..., p_notification=25) at scene/main/scene_tree.cpp:1139
#21 0x0000000003627fff in SceneTree::idle (this=0x701c9b0, p_time=0.0069444445) at scene/main/scene_tree.cpp:635
#22 0x00000000018a6fa7 in Main::iteration () at main/main.cpp:2361
#23 0x00000000018692a8 in OS_X11::run (this=0x7fffffffcc50) at platform/x11/os_x11.cpp:4047
#24 0x0000000001854cc2 in main (argc=2, argv=0x7fffffffd608) at platform/x11/godot_x11.cpp:59
So despite the correct error that find_node
can't be called on a non-instance, the auto-completion code still triggers that call anyway to guess the return type, so it crashes.
find_node
is being called on Script
which is a resource, not a node, hence the crash I think.
This traces back to baseptr
pointing to this Script
and not a node in _guess_expression_type
.
This probably needs @vnen to look at.
Godot version
v3.6.beta2.official [68c507f59]
System information
w10 64
Issue description
Godot crashes when I use find_node in the wrong way.
SCRIPT ERROR: Parse error: Non-static function "find_node" can only be called from an instance.
https://github.com/godotengine/godot/assets/19652075/d6d1fa53-e813-4e8f-a4b8-b4606452b663
Steps to reproduce
In the video
Minimal reproduction project
I'm not sure I can reproduce this or that it is necessary to do so.