Skip to content

Can't bind two integer from different enums #1910

@thiagola92

Description

@thiagola92

Godot version

v4.6.beta2.official [551ce8d47]

godot-cpp version

master (d9eab9e)

System information

Godot v4.6.beta2 - Fedora Linux 43 (Workstation Edition) on Wayland - X11 display driver, Multi-window, 2 monitors - OpenGL 3 (Compatibility) - NV136 - Intel(R) Core(TM) i5-7600K CPU @ 3.80GHz (4 threads) - 31.16 GiB memory

Issue description

I'm making a GDExtension and I'm trying to reproduce a GDScript code:

extends RefCounted


enum Example {
	VALUE = 1,
}

enum Example2 {
	VALUE = 1,
}


func _ready() -> void:
	print(Example.VALUE)
	print(Example2.VALUE)

But passing constants with the same name to bind_integer_constant() fail:

void ExampleClass::_bind_methods() {
    ClassDB::bind_integer_constant(get_class_static(), "Example", "VALUE", 1);

    // ERROR: Constant 'ExampleClass::VALUE' already registered.
    //    at: bind_integer_constant (godot-cpp/src/core/class_db.cpp:278)
    ClassDB::bind_integer_constant(get_class_static(), "Example2", "VALUE", 1);
}

Important to note that enum names are different.

Steps to reproduce

Just follow the GDExtension example and replace with the code above.

Minimal reproduction project

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions