-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
GDScript 2.0: Cannot parse match with typeof() and enum constants from other script #63535
Comments
I'm looking into it :) |
@cassandrus @Calinou Actually after much debugging I think this may not be an error, it could be intended behavior. Original Project settings (.tscn is autoload) resulting in error: |
Firstly, if it has common reason with #44375 (and it's very much possible as it's the same project and "incorrectly enabled" auto-load singleton) and it is intended, it's still seems like a bug as it shows "parser error" there (instead of sane explanation of why I can't do this). Secondly, I don't think it's intended behavior or incorrect use of singleton. Auto-load also says "Node name" -> "Add". I'm sure more experienced devs can say more, but when you use these global enums, they actually work in runtime without issues, the only problem is declaring them as constant types in switch or in type hints.. Thirdly, if it's unsupported feature, I think it should be supported. What I'm trying here is to make auto-load Node with a bunch of @export vars in script that are used for some global game settings. Thus, I use them both in scripts and edit them in Inspector - very handy for fast editing of configs. |
@cassandrus i don´t think your code example makes sense, when you call i think the right example would be
that being said, the error still occurs, i am wondering if it could have to do with the order in which the GdScript parser analizes the sources |
Could not reproduce on master (fcba87e) as I ran the MRP sucessfully, without any errors (both the editor and the runtime)! I consider this issue fixed. @akien-mga |
Godot version
Godot Engine v4.0.alpha12.official
System information
Windows 10
Issue description
When enum from another script (auto-load singleton) is used as case for a match expression, it fails with "Expression in match pattern must be a constant".
Built-in enums like TYPE_STRING work as expected. Enums declared in the same script work too.
I've decided not to add this report as part of #52033 as error texts are different. Also, I've recently filed report to #44375 where I also had problems with enums from singleton but on static typing (perhaps problems are related).
Followup:
I tried to use script that is declared through class_name insted of singleton auto-load script. It works this way. So the problem is only with singleton declarations (I;m starting to doubt if this is intended?).
Error:
Steps to reproduce
Just use enum from another script. I've also added mini-project to save your time.
Minimal reproduction project
game-client_test2.zip
The text was updated successfully, but these errors were encountered: