You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I wanted to customize text_bubble.gd and therefore copied it to some local custom_text_bubble.gd (the same way as Dialogic offers a built-in way to customize Layers, creating custom_text_bubble_layer.tscn and text_bubble_layer.gd, but going further and also copying custom_text_bubble.tscn and its script).
However, the code revealed to trigger some code warning, which by default is treated as an error:
func _process(delta:float) -> void:# ...
var dist_x := abs(base_position.x - center.x) # Line 54
var dist_y := abs(base_position.y - center.y) # Line 55
Line 54:The variable type is being inferred from a Variant value, so it will be typed as Variant. (Warning treated as error.)
and same for Line 55
They can be disabled by unchecking project setting:
debug/gdscript/warnings/inference_on_variant (Inference on Variant)
however it seems cleaner to handle these properly in code. In this case, using absf instead of abs (in fact I had exactly the same issue on my own addon so it helped me find where the issue was).
Add-on code is not parsed by default, so this only appears when duplicating code to local project sub-folder for customization, or when disabling Project Settings > debug/gdscript/warnings/exclude_addons, in which case you get even another warning:
res://addons/dialogic/Modules/Character/subsystem_portraits.gd
var test := dialogic.Expressions.execute_string(portrait) # Also Inference on Variant
but this one is really a variant, so there is nothing clever to do except replacing := with = I suppose.
To Reproduce
Steps to reproduce the behavior:
Disable Project Settings > debug/gdscript/warnings/exclude_addons OR duplicate text_bubble.gd and subsystem_portraits.gd to project sub-folder
Make sure that debug/gdscript/warnings/inference_on_variant is set to Error
Wait for parser error to appear, or Play to force parse
See warnings treated as errors
Expected behavior
No code warnings (even less ones treated as errors by default).
Screenshots
System (please complete the following information):
OS: Linux Ubuntu 22.04
Godot Version: v4.2.1.stable.official [b09f793f5]
Dialogic Version: main commit a9c56aa (2024-05-05)
Solutions
Possible fixes
Use precise type methods absf in text_bubble.gd, and don't use static typing at all in subsystem_portraits.gd for the test variable, to avoid all warnings.
The text was updated successfully, but these errors were encountered:
hsandt
added a commit
to hsandt/lospec-jam-2-scaled-down-adventures
that referenced
this issue
May 22, 2024
Appreciate the report. This is absolutely something we can and should do!
Btw, while I really like that you take a lot of time to report and investigate these issues, feel free to keep the description a bit shorter for simple things like this. Especially if you are pretty certain what causes the bug.
E.g. in this case it would have been enough for me to say something like this:
When making the textbubble layer custom, these lines give an error (with default error/warning settings):
...
*Error Message*
It can easily be fixed by using `absf()` instead of `abs()`
Also the type inference in SubsystemPortraits line x fails and should be explicit.
...
Just to give an example. Don't get me wrong, long issues are good, especially when people don't know what the problem is, but for things like this, feel free to condense it and save yourself some time ;)
The problem
Describe the bug
I wanted to customize text_bubble.gd and therefore copied it to some local custom_text_bubble.gd (the same way as Dialogic offers a built-in way to customize Layers, creating custom_text_bubble_layer.tscn and text_bubble_layer.gd, but going further and also copying custom_text_bubble.tscn and its script).
However, the code revealed to trigger some code warning, which by default is treated as an error:
and same for Line 55
They can be disabled by unchecking project setting:
debug/gdscript/warnings/inference_on_variant (Inference on Variant)
however it seems cleaner to handle these properly in code. In this case, using
absf
instead ofabs
(in fact I had exactly the same issue on my own addon so it helped me find where the issue was).Add-on code is not parsed by default, so this only appears when duplicating code to local project sub-folder for customization, or when disabling Project Settings > debug/gdscript/warnings/exclude_addons, in which case you get even another warning:
res://addons/dialogic/Modules/Character/subsystem_portraits.gd
var test := dialogic.Expressions.execute_string(portrait) # Also Inference on Variant
but this one is really a variant, so there is nothing clever to do except replacing
:=
with=
I suppose.To Reproduce
Steps to reproduce the behavior:
Expected behavior
No code warnings (even less ones treated as errors by default).
Screenshots
System (please complete the following information):
Solutions
Possible fixes
Use precise type methods
absf
in text_bubble.gd, and don't use static typing at all in subsystem_portraits.gd for thetest
variable, to avoid all warnings.The text was updated successfully, but these errors were encountered: