Sudden error with enum as type?

Godot Version

4.3 Stable

Question

Hi,

Today I opened my project to find one of my lines of code has randomly broken.

enum Types {EARTH, WATER, FIRE, ELECTRIC, PHYSICAL, DARK}
@export var type := TypeHandler.Types.WATER ← error here

Parser Error: Cannot infer the type of “type” variable because the value doesn’t have a set type.

I’ve had this line of code in my project for so long. Why is it suddenly throwing an error?

Note: The enum lives in an auto loaded singleton but that was never an issue before.

Naturally, the engine checks scripts before setting up autoloads (especially for the autoload script itself), so it cannot find the TypeHandler during parsing and gives an error. In which file did you use this line?

I have a custom resource file called basic_monster.gd that I use it in, but I actually use this in quite a few places. This seems to be the only one that has an error. I just don’t understand why it would randomly start doing this because it has never been an issue before.

Deleting the autoload and setting it up again seems to have solved the problem. Thanks for the help!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.