Skip to content

TypedArray and TypedDictionary do not allow enums as template parameters #1684

Open
@BenLubar

Description

@BenLubar

Godot version

4.4.dev7.official.46c8f8c5c

godot-cpp version

befe3ee

System information

Debian Trixie, i7-1360P

Issue description

Related to #1584, although the introduction of typed dictionaries makes this much more complicated.

TypedArray and TypedDictionary should be able to take enum types that have been registered with VARIANT_ENUM_CAST as the element or key or value type, treating it as an integer with whatever metadata is needed to make the editor show the correct type name in the brackets.

Steps to reproduce

Contrived toy example:

class Foo : public Object {
    GDCLASS(Foo, Object);

protected:
    static void _bind_methods();

public:
    enum Animal {
        CAT,
        DOG,
        HORSE,
    };

    TypedArray<Animal> get_animals_that_should_go_in_a_house() const;
    TypedDictionary<Animal, ArrayMesh> get_animal_meshes() const;
};

VARIANT_ENUM_CAST(Foo::Animal);

Actual project where I am using typed arrays and dictionaries of enum types: https://github.com/BenLubar/godot4-spy-cards-online
(In the actual project, src/dry.h contains a lot of helper macros.)

Minimal reproduction project

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis has been identified as a bug

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions