godotengine / godotengine/godot

Spurious Warning on Menu Accelerators With Mask Modifiers

Open
#101,320 0 comments 0 reactions 0 assignees View on GitHub
bug topic:gdscript
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

Reproducible in 4.3dev

### System information

N/A

### Issue description

Adding accelerators the documented way is creating spurious warnings when a modifier mask is used.
NOTE: I already checked, it's not the 2nd parameter that's the error since the 1st line here does not get an error.
```gdscript
popup.add_item("Rail Line", -1, KEY_T)
popup.add_item("Train Station", -1, KEY_MASK_CTRL | KEY_MASK_SHIFT | KEY_T)
popup.add_item("Freight Depot", -1, KEY_MASK_ALT | KEY_T)
```

The errors for the 2nd and 3rd items are:
```
W 0:00:02:0329 Integer used when an enum value is expected. If this is intended cast the integer to the enum type.
INT_AS_ENUM_WITHOUT_CAST
new_tools_container.tscn::GDScript_erqco:10
W 0:00:02:0329 Cannot pass 301989972 as Enum "Key": no enum member has matching value.
INT_AS_ENUM_WITHOUT_MATCH
new_tools_container.tscn::GDScript_erqco:10
W 0:00:02:0329 Integer used when an enum value is expected. If this is intended cast the integer to the enum type.
INT_AS_ENUM_WITHOUT_CAST
new_tools_container.tscn::GDScript_erqco:11
W 0:00:02:0329 Cannot pass 67108948 as Enum "Key": no enum member has matching value.
INT_AS_ENUM_WITHOUT_MATCH
new_tools_container.tscn::GDScript_erqco:11
```

I don't expect this since this is what the docs say to do:
![Image](https://github.com/user-attachments/assets/b8c69c88-548a-4f06-91cb-713669179309)

### Steps to reproduce

Given above small script ^^^

### Minimal reproduction project (MRP)

N/A its in the docs

Contributor guide

Open the contributing guide

Research direction

Start with the documented accelerator example and the small GDScript reproduction in the issue, then trace where modifier-mask values are checked against the Key enum. Confirm the fix by rerunning the reproduction and verifying that Ctrl+Shift+T and Alt+T produce no enum warnings while the accelerators still work.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.