Skip to content

Can't use VARIANT_ENUM_CAST with enum class #1917

@NoctemCat

Description

@NoctemCat

Godot version

4.5.1.stable.mono

godot-cpp version

godot-4.5-stable

System information

Godot v4.5.1.stable.mono unknown - EndeavourOS #1 SMP PREEMPT_DYNAMIC Sun, 11 Jan 2026 17:10:53 +0000 on X11 - X11 display driver, Multi-window, 2 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1650 (nvidia; 590.48.01) - Intel(R) Core(TM) i5-9300H CPU @ 2.40GHz (8 threads) - 15.49 GiB memory

Issue description

VARIANT_ENUM_CAST doesn't work with enum class, looks like you need to change p_val to static_cast<int64_t>(p_val) in PtrToArg<m_enum>::encode.

VARIANT_ENUM_CAST does work in Godot itself with enum classes.

Also I guess VARIANT_BITFIELD_CAST is the same, and the master still has the same code, so it looks like the issue is still exist

Steps to reproduce

Use VARIANT_ENUM_CAST with enum class

Minimal reproduction project

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementThis is an enhancement on the current functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions