Skip to content

GDScript 2.0: Enum values can't be compared to variable integers #50293

@vntxx

Description

@vntxx

Godot version

v4.0.dev.calinou [bfc14a6]

System information

Windows 10

Issue description

Once comparing an enum against an integer in code it will be marked as an error. I am assuming that this is a regression since it did work in GDScript 1.0 (Godot 3.x). Note that this behaviour occurs regardless of the enum value having an integer value assigned to it.

Steps to reproduce

Compare an enum value against an integer inside a GDScript file (see below)

Minimal reproduction project

Create a new GDScript file inside the engine and paste the following:

enum SomeEnum {
	VALUE = 1
}

func function():
	if 0 == SomeEnum.VALUE:
		pass
	
	const integer_const: int = 1
	if integer_const == SomeEnum.VALUE:
		pass
	
	var integer_var: int = 1
	if integer_var == SomeEnum.VALUE: # Error
		pass

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions