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

Crash when using a multi-line ternary in @exports #50714

Closed
Tracked by #40488
t3nk3y opened this issue Jul 21, 2021 · 2 comments · Fixed by #52706
Closed
Tracked by #40488

Crash when using a multi-line ternary in @exports #50714

t3nk3y opened this issue Jul 21, 2021 · 2 comments · Fixed by #52706

Comments

@t3nk3y
Copy link

t3nk3y commented Jul 21, 2021

Godot version

Engine v4.0.dev.custom_build.3478690c0

System information

Ubuntu 21.04

Issue description

When using a multi-line @exports statement that contains a ternary operator, the editor will crash.
This crashes the editor if the script exists anywhere in the project.

This crashes the editor:

@export var this_is_a_string = "":
	get:
		return "test" if true else
		"break"

This works fine:

@export var this_is_a_string = "":
	get:
		return "test" if true else "break"

Crashdump below:

handle_crash: Program crashed with signal 11
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x41040) [0x7ff78318d040] (??:0)
[2] GDScriptCompiler::_parse_expression(GDScriptCompiler::CodeGen&, Error&, GDScriptParser::ExpressionNode const*, bool, bool, GDScriptCodeGenerator::Address const&) (/godot/modules/gdscript/gdscript_compiler.cpp:208)
[3] GDScriptCompiler::_parse_expression(GDScriptCompiler::CodeGen&, Error&, GDScriptParser::ExpressionNode const*, bool, bool, GDScriptCodeGenerator::Address const&) (/godot/modules/gdscript/gdscript_compiler.cpp:836)
[4] GDScriptCompiler::_parse_block(GDScriptCompiler::CodeGen&, GDScriptParser::SuiteNode const*, bool) (/godot/modules/gdscript/gdscript_compiler.cpp:1737)
[5] GDScriptCompiler::_parse_setter_getter(GDScript*, GDScriptParser::ClassNode const*, GDScriptParser::VariableNode const*, bool) (/godot/modules/gdscript/gdscript_compiler.cpp:2098)
[6] GDScriptCompiler::_parse_class_blocks(GDScript*, GDScriptParser::ClassNode const*, bool) (/godot/modules/gdscript/gdscript_compiler.cpp:2469)
[7] GDScriptCompiler::compile(GDScriptParser const*, GDScript*, bool) (/godot/modules/gdscript/gdscript_compiler.cpp:2624)
[8] GDScript::reload(bool) (/godot/modules/gdscript/gdscript.cpp:846)
[9] GDScriptLanguage::reload_tool_script(Ref<Script> const&, bool) (/godot/modules/gdscript/gdscript.cpp:1893)
[10] ResourceFormatSaverGDScript::save(String const&, Ref<Resource> const&, unsigned int) (/godot/modules/gdscript/gdscript.cpp:2324)
[11] ResourceSaver::save(String const&, Ref<Resource> const&, unsigned int) (/godot/core/io/resource_saver.cpp:116)
[12] EditorNode::save_resource_in_path(Ref<Resource> const&, String const&) (/godot/editor/editor_node.cpp:1099)
[13] EditorNode::save_resource(Ref<Resource> const&) (/godot/editor/editor_node.cpp:1117)
[14] ScriptEditor::save_current_script() (/godot/editor/plugins/script_editor_plugin.cpp:2330)
[15] EditorNode::_menu_option_confirm(int, bool) (/godot/editor/editor_node.cpp:?)
[16] EditorNode::_menu_option(int) (/godot/editor/editor_node.cpp:1197)
[17] void call_with_variant_args_helper<EditorNode, int, 0ul>(EditorNode*, void (EditorNode::*)(int), Variant const**, Callable::CallError&, IndexSequence<0ul>) (/godot/./core/variant/binder_common.h:223)
[18] void call_with_variant_args<EditorNode, int>(EditorNode*, void (EditorNode::*)(int), Variant const**, int, Callable::CallError&) (/godot/./core/variant/binder_common.h:333)
[19] CallableCustomMethodPointer<EditorNode, int>::call(Variant const**, int, Variant&, Callable::CallError&) const (/godot/./core/object/callable_method_pointer.h:97)
[20] Callable::call(Variant const**, int, Variant&, Callable::CallError&) const (/godot/core/variant/callable.cpp:51)
[21] Object::emit_signal(StringName const&, Variant const**, int) (/godot/core/object/object.cpp:1099)
[22] Object::emit_signal(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&) (/godot/core/object/object.cpp:1154)
[23] PopupMenu::activate_item(int) (/godot/scene/gui/popup_menu.cpp:1379)
[24] PopupMenu::activate_item_by_event(Ref<InputEvent> const&, bool) (/godot/scene/gui/popup_menu.cpp:1305)
[25] MenuButton::_unhandled_key_input(Ref<InputEvent>) (/godot/scene/gui/menu_button.cpp:52)
[26] void call_with_variant_args_helper<__UnexistingClass, Ref<InputEvent>, 0ul>(__UnexistingClass*, void (__UnexistingClass::*)(Ref<InputEvent>), Variant const**, Callable::CallError&, IndexSequence<0ul>) (/godot/./core/variant/binder_common.h:218)
[27] void call_with_variant_args_dv<__UnexistingClass, Ref<InputEvent> >(__UnexistingClass*, void (__UnexistingClass::*)(Ref<InputEvent>), Variant const**, int, Callable::CallError&, Vector<Variant> const&) (/godot/./core/variant/binder_common.h:366)
[28] MethodBindT<Ref<InputEvent> >::call(Object*, Variant const**, int, Callable::CallError&) (/godot/./core/object/method_bind.h:285)
[29] SceneTree::_call_input_pause(StringName const&, StringName const&, Ref<InputEvent> const&, Viewport*) (/godot/scene/main/scene_tree.cpp:903)
[30] Viewport::unhandled_input(Ref<InputEvent> const&, bool) (/godot/scene/main/viewport.cpp:3118)
[31] Window::_window_input(Ref<InputEvent> const&) (/godot/scene/main/window.cpp:920)
[32] void call_with_variant_args_helper<Window, Ref<InputEvent> const&, 0ul>(Window*, void (Window::*)(Ref<InputEvent> const&), Variant const**, Callable::CallError&, IndexSequence<0ul>) (/godot/./core/variant/binder_common.h:218)
[33] void call_with_variant_args<Window, Ref<InputEvent> const&>(Window*, void (Window::*)(Ref<InputEvent> const&), Variant const**, int, Callable::CallError&) (/godot/./core/variant/binder_common.h:333)
[34] CallableCustomMethodPointer<Window, Ref<InputEvent> const&>::call(Variant const**, int, Variant&, Callable::CallError&) const (/godot/./core/object/callable_method_pointer.h:97)
[35] Callable::call(Variant const**, int, Variant&, Callable::CallError&) const (/godot/core/variant/callable.cpp:51)
[36] DisplayServerX11::_dispatch_input_event(Ref<InputEvent> const&) (/godot/platform/linuxbsd/display_server_x11.cpp:2662)
[37] DisplayServerX11::_dispatch_input_events(Ref<InputEvent> const&) (/godot/platform/linuxbsd/display_server_x11.cpp:2646)
[38] Input::_parse_input_event_impl(Ref<InputEvent> const&, bool) (/godot/core/input/input.cpp:643)
[39] Input::parse_input_event(Ref<InputEvent> const&) (/godot/core/input/input.cpp:466)
[40] Input::flush_accumulated_events() (/godot/core/input/input.cpp:858)
[41] DisplayServerX11::process_events() (/godot/platform/linuxbsd/display_server_x11.cpp:3496)
[42] OS_LinuxBSD::run() (/godot/platform/linuxbsd/os_linuxbsd.cpp:274)
[43] /godot.linuxbsd.tools.64.llvm(main+0x1cb) [0x490dc7b] (/godot/platform/linuxbsd/godot_linuxbsd.cpp:58)
[44] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xd5) [0x7ff783174565] (??:0)
[45] /godot.linuxbsd.tools.64.llvm(_start+0x2e) [0x490d9ee] (??:?)
-- END OF BACKTRACE --

Steps to reproduce

  1. Create a project
  2. Create a script
  3. Add @exports line that contains a ternary operator that spans to the next line. See example below, in description, and attached project.
extends Node

@export var this_is_a_string = "":
	get:
		return "test" if true else
		"break"

Minimal reproduction project

exports-crash.zip

@Calinou
Copy link
Member

Calinou commented Jul 22, 2021

Are such multiline ternary operators supported in the first place? I think you need to escape the line breaks using \ or wrap the expression within parentheses (which then allows freely breaking lines without using backslashes).

@t3nk3y
Copy link
Author

t3nk3y commented Jul 22, 2021

Perhaps the problem is actually that the editor is showing it as valid then?
I was thinking the "else" allowed the line break, and the editor seems to agree.

I mean, either way, I think the editor crashing on save, and when opening the project is a bug that needs fixed.

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

Successfully merging a pull request may close this issue.

3 participants