-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Autocompletion breaks until the editor is restarted when a cyclic reference occurs #78074
Comments
Could you test the latest builds of Godot 4.1 (beta 3 at the time of writing) and compare? |
Just tried with the Godot 4.1 RC 1, and it's still there |
I confirm that the issue is still there in Godot 4.1.1 stable.
class_name Foo extends Node
func bar() -> int:
return 5 class_name Mob extends Node
@onready var foo: Foo = get_node("Foo")
func _ready():
foo.bar() // autocomplete succeeds extends Node
@onready var mob: Mob = get_node("Mob")
func _ready():
mob.foo.bar() // autocomplete fails |
Did further testing, it looks like autocompletion works for members of the base class (e.g. Node2D), just not for custom members of the child class. Similarly, Ctrl+click won't work at all. I tried VS Code + GDScript plugin as a workaround, but it doesn't work either - I suspect because the language server asks Godot for autocompletion, but Godot has the bug so it propagates to VS Code. |
Having the same problem. Did anyone find a solution? |
Looking at this I think it is not quite clear which issue we are talking about. The OP looks like a reload problem with Cyclic references.
This is a different setup without cyclic references. |
I think I'm running into this quite a bit, I'm running on a modified version of 4.3dev3 and was wondering if something I did in my modifications was causing the behavior but after looking at this and other similar issues it seems to be a known issue. I find myself restarting the editor a lot when coding. If I'm mostly in the same file it's fine, but the moment I need to edit a file that's referenced by a lot of others, I ran into the issue and have to restart. Since the restart seems to fix it I guess a possible solution would be some sort of "clean and rebuild autocomplete cache" or something? Perhaps adding a button to the GDScript "File menu" similar to the existing "Soft Reload Tool Script" but a "Rebuild Autocompletion Cache" button? (When I was trying to find solutions that was one of the first things/places I looked) |
I'm not 100% certain if cyclic reference per se causes the autocomplete break. I've had cyclic references in my v4.2.stable.official [46dc277] version and the autocomplete was working fine until I copy-pasted some code into the project. The code causes an error, I immediately commented the whole thing but the autocomplete is irrevocably broken after that. It's really frustrating. This bug has been around since 4.0 iirc. (Probably unrelated: enums doesn't autocomplete if it's in a match block or if invoked from an instance instead of the class name.) |
I'm not sure if rebuilding the cache matters, I tried deleting and regenerating the .godot folder which contains all cache files but autocompletion remains broken |
Can also confirm this. It is highly reproducible with specific scripts and not others. And, like it was noted above, it does not seem solely related to the presence of cyclic references (there appears to be at least one other trigger required, perhaps a threshold number of references?), and deleting the .godot folder does not fix the problem. It currently appears that there are three possible outcomes that may be different stages of same problem. As the project grows and the cross-referencing complexity increases, the scripts that are affected by (1) later become affected by (2) and then (3). Not being familiar with the core code, I wonder if perhaps these reflect different levels of recursion timeouts or other limitations leading to different fail states? Edit: To clarify, the errors occur when adding a new member to the affected script, then attempting to reference that member from another script. (1) Autocomplete fails, but no errors are reported in the editor or running the game. This progression has been consistent for me across many projects. The first script affected is always the file that contains my global constants. It does not reference any other script, but many scripts reference it, and some of them contain cyclic references. The next scripts to become affected are usually superclasses with multiple subclasses and users (like a generic "Entity" script). I start to see the process starting around the time the projects grow from about a dozen scripts to a few dozen scripts -- so they are still relatively small. |
CC @godotengine/gdscript |
Thanks for looking into it! I want to clarify that I'm not 100% sure that it's the same problem as the original post, but it matches #80674, which was closed as being the same cause as this issue. And @LO-0116's observations seemed consistent with my experience that it has not been just cyclic references, but seems to require a second trigger. |
Another thing I've noticed: static functions does not seem affected by broken auto-completes. That is to say, autocompletes that wouldn't work in the body of |
I tried to reproduce on When auto completion shows old names, outdated class types are set by the analyzer. This happens because the new parser created by On a different note, with #84266 I wasn't able to reproduce even with the cyclic references, I suppose it forces an update on the cache. This isn't the correct fix for this issue though. Also the bug I found here, does not really fit all users who reported on having this problem in this thread. There have been some fixes with GDScript caching so I could imagine, that some more grave issues were already fixed by them. Did anyone with the problem give it a try with the last dev build? |
@HolonProduction So far, the issue I described appears not to be reproducible in 4.3-dev6! When I try to access newly-added variables from the previously affected scripts, autocomplete is populating immediately and there are no errors. Going back and forth with the same project in 4.3-dev5 still reproduces the errors I described. |
Update: this also breaks after adding enough things to the project. I get the feeling now that the autocomplete breaking is not a matter of quality but a matter of quantity. i.e.: when there are too many things to autocomplete, the autocompletion deteriorates, starting with "vulnerable" things like classes with cyclic references then eventually affecting even less vulnerable things like static functions |
I feel like now I have a new version of this issue, which now spawns a new error. In general, I feel like the issue has been mostly solved, the autocompletion seems to be way more resilient to code changes and in places where they would often break before it stays working just fine in 4.3beta1. But every once in a while I noticed I would get errors like this spammed in the output: USER ERROR: Parser bug: Mismatched external parser. The error message doesn't tell me much, so I went digging around. The error was coming from this method in void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class, int p_index, const GDScriptParser::Node *p_source) { ERR_FAIL_COND_MSG(!parser_ref->get_parser()->has_class(p_class), R"(Parser bug: Mismatched external parser.)"); So I added these before it to catch some more information: if (!parser_ref->get_parser()->has_class(p_class)) {
if (p_class == nullptr) {
push_error(vformat(R"(Parser did not have class NULLPTR script "%s" member "%s")",script_path,member.get_name()),p_source);
} else {
push_error(vformat(R"(Parser did not have class %s script "%s" member "%s")",p_class->get_global_name(), script_path,member.get_name()),p_source);
}
} I think it would be good in general to include some more information in that error. It took a while to happen in the editor again, but in the meantime it popped up in a build for me. USER ERROR: Parser bug: Mismatched external parser.
at: GDScriptAnalyzer::resolve_class_member (modules\gdscript\gdscript_analyzer.cpp:916)
USER SCRIPT ERROR: Parse Error: Parser did not have class Skill script "res://resources/skill.gd" member "found_button"
at: GDScript::reload (res://resources/skill.gd:100)
USER SCRIPT ERROR: Parse Error: Parser did not have class Skill script "res://resources/skill.gd" member "relevant_button_ui"
at: GDScript::reload (res://resources/skill.gd:103) The code in question was this, which was in the for skill in p.current_skills:
if skill.found_button:
continue
skill.button_desired = "skill_"+str(non_ult_non_mov_skill_count+1)
skill.relevant_button_ui.texture = App.skill_glyphs[non_ult_non_mov_skill_count]
non_ult_non_mov_skill_count+= 1
skill.found_button=true That error was present every time I built, that one was pretty reproducible. I tried building an MRP trying to do a similar thing but I couldn't get an MRP to reproduce the same error. I noticed I had not typecasted I'm not sure why the error on builds happened, but this script used to be fine when I was using a previous 4.3dev so I'm assuming some sort of regression. Now back to the editor, took a while but the same In this case the script (the one in Should I start a new issue or is this still related to the same issue? So far it seems to happen way more rarely than the original issue, and I can't seem to make an MRP for it as it happens semi-randomly while working. I'm also running a custom build with custom modules so I can't 100% say it isn't related to my own custom code. |
@godotengine/bugsquad Can we please close this issue? As per the comment of @dandeliondino the original issue seems to be not a problem anymore. The other problems/issues mentioned in this thread require different conditions than the original report and should be their own issue with an MRP. The way it currently is, it's just not possible to reproduce, work on or keep track of any of them. @DanielSnd please create a new issue including an MRP if this issue is still present with 4.3.beta3. Same to all other users who encountered loosely related problems. (This issue is about cyclic dependencies and outdated members. Anything else belongs in an own report.) |
Closing the issue as the MRP behaves as it should on v4.3.beta.custom_build [26d1577] (latest master). |
Godot version
4.0.3 stable
System information
Windows 10
Issue description
Something is breaking the autocompletion when I used 2nd degree or more member of a variable.
Here's an exemple:
And
If you rename
get_num
toget_numb
for exemple, the autocompletion in MyClassB will continue to showget_num
(and CTRL+Click to it will refer toget.num
), and I need to reload all the project because all future autocompletion will be outdated (like it stopped to update)By the way, maybe it's related to #78003
I tested with the 4.1Beta, it still present
(First issue, I hope it's complete enough 😄)
Steps to reproduce
get_num
toget_numb
(or something else) in MyClassAclassA.classB.classA.
Minimal reproduction project
Issue.zip
The text was updated successfully, but these errors were encountered: